Skip to content

Commit

Permalink
Merge pull request #4 from fabi200123/unit-tests
Browse files Browse the repository at this point in the history
Adding unit-tests
  • Loading branch information
gabriel-samfira authored Apr 19, 2024
2 parents 562539f + 8d7262f commit c18a62d
Show file tree
Hide file tree
Showing 502 changed files with 11,100 additions and 92,336 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/go-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Go Tests

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
go-tests:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup Golang
uses: actions/setup-go@v3
with:
go-version-file: go.mod

- run: go version

- name: Run GARM Go Tests
run: make go-test
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
SHELL := bash

.PHONY: go-test

go-test:
go test -v ./... $(TEST_ARGS) -timeout=15m -parallel=4
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ To this end, this provider supports the following extra specs schema:
"enable_boot_debug": {
"type": "boolean",
"description": "Allows providers to set the -x flag in the runner install script."
},
"additionalProperties": false
}
}
},
"additionalProperties": false
}
```

Expand Down
8 changes: 4 additions & 4 deletions config/lxd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func TestLXDWithInvalidUnixSocket(t *testing.T) {
cfg.UnixSocket = "bogus unix socket"
err := cfg.Validate()
require.NotNil(t, err)
require.EqualError(t, err, "could not access unix socket bogus unix socket: \"stat bogus unix socket: no such file or directory\"")
require.EqualError(t, err, "could not access unix socket bogus unix socket: \"CreateFile bogus unix socket: The system cannot find the file specified.\"")
}

func TestMissingUnixSocketAndMissingURL(t *testing.T) {
Expand Down Expand Up @@ -134,14 +134,14 @@ func TestLXDIvalidCertOrKeyPaths(t *testing.T) {
cfg.ClientCertificate = "/i/am/not/here"
err := cfg.Validate()
require.NotNil(t, err)
require.EqualError(t, err, "failed to access client certificate /i/am/not/here: \"stat /i/am/not/here: no such file or directory\"")
require.EqualError(t, err, "failed to access client certificate /i/am/not/here: \"CreateFile /i/am/not/here: The system cannot find the path specified.\"")

cfg.ClientCertificate = "../testdata/lxd/certs/client.crt"
cfg.ClientKey = "/me/neither"

err = cfg.Validate()
require.NotNil(t, err)
require.EqualError(t, err, "failed to access client key /me/neither: \"stat /me/neither: no such file or directory\"")
require.EqualError(t, err, "failed to access client key /me/neither: \"CreateFile /me/neither: The system cannot find the path specified.\"")
}

func TestLXDInvalidServerCertPath(t *testing.T) {
Expand All @@ -150,7 +150,7 @@ func TestLXDInvalidServerCertPath(t *testing.T) {

err := cfg.Validate()
require.NotNil(t, err)
require.EqualError(t, err, "failed to access tls_server_certificate /not/a/valid/server/cert/path: \"stat /not/a/valid/server/cert/path: no such file or directory\"")
require.EqualError(t, err, "failed to access tls_server_certificate /not/a/valid/server/cert/path: \"CreateFile /not/a/valid/server/cert/path: The system cannot find the path specified.\"")
}

func TestInvalidLXDImageRemotes(t *testing.T) {
Expand Down
40 changes: 14 additions & 26 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,36 +1,31 @@
module github.com/cloudbase/garm-provider-lxd

go 1.21.5
go 1.22.0

toolchain go1.22.1

require (
github.com/BurntSushi/toml v1.2.1
github.com/canonical/lxd v0.0.0-20231214113525-e676fc63c50a
github.com/canonical/lxd v0.0.0-20240417071759-c8bc5de197b0
github.com/cloudbase/garm-provider-common v0.1.2-0.20240111235646-a9efac12b060
github.com/gorilla/websocket v1.5.1
github.com/juju/clock v1.0.3
github.com/juju/retry v1.0.0
github.com/pkg/errors v0.9.1
github.com/stretchr/testify v1.8.4
github.com/stretchr/testify v1.9.0
github.com/xeipuuv/gojsonschema v1.2.0
)

require (
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/felixge/httpsnoop v1.0.3 // indirect
github.com/flosch/pongo2 v0.0.0-20200913210552-0d938eb266f3 // indirect
github.com/frankban/quicktest v1.14.3 // indirect
github.com/go-macaroon-bakery/macaroon-bakery/v3 v3.0.1 // indirect
github.com/go-macaroon-bakery/macaroonpb v1.0.0 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/uuid v1.4.0 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/gorilla/handlers v1.5.1 // indirect
github.com/gorilla/schema v1.2.1 // indirect
github.com/gorilla/schema v1.3.0 // indirect
github.com/gorilla/securecookie v1.1.2 // indirect
github.com/gorilla/websocket v1.5.1 // indirect
github.com/juju/errors v1.0.0 // indirect
github.com/juju/testing v1.0.2 // indirect
github.com/juju/webbrowser v1.0.0 // indirect
github.com/julienschmidt/httprouter v1.3.0 // indirect
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
github.com/kr/fs v0.1.0 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
Expand All @@ -39,27 +34,20 @@ require (
github.com/pkg/sftp v1.13.6 // indirect
github.com/pkg/xattr v0.4.9 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/robfig/cron/v3 v3.0.1 // indirect
github.com/rogpeppe/fastuuid v1.2.0 // indirect
github.com/rogpeppe/go-internal v1.12.0 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/stretchr/objx v0.5.2 // indirect
github.com/teris-io/shortid v0.0.0-20220617161101-71ec9f2aa569 // indirect
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f // indirect
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
github.com/zitadel/oidc/v2 v2.12.0 // indirect
golang.org/x/crypto v0.16.0 // indirect
golang.org/x/net v0.19.0 // indirect
golang.org/x/oauth2 v0.15.0 // indirect
golang.org/x/sys v0.15.0 // indirect
golang.org/x/term v0.15.0 // indirect
golang.org/x/crypto v0.22.0 // indirect
golang.org/x/net v0.24.0 // indirect
golang.org/x/oauth2 v0.19.0 // indirect
golang.org/x/sys v0.19.0 // indirect
golang.org/x/term v0.19.0 // indirect
golang.org/x/text v0.14.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/protobuf v1.31.0 // indirect
gopkg.in/errgo.v1 v1.0.1 // indirect
gopkg.in/httprequest.v1 v1.2.1 // indirect
gopkg.in/macaroon.v2 v2.1.0 // indirect
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
gopkg.in/square/go-jose.v2 v2.6.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading

0 comments on commit c18a62d

Please sign in to comment.