diff --git a/.github/workflows/go-tests.yml b/.github/workflows/go-tests.yml index 534d96a..303d47c 100644 --- a/.github/workflows/go-tests.yml +++ b/.github/workflows/go-tests.yml @@ -9,7 +9,7 @@ on: - main jobs: - go-tests: + go-tests-linux: runs-on: ubuntu-latest steps: @@ -24,4 +24,21 @@ jobs: - run: go version - name: Run GARM Go Tests - run: make go-test \ No newline at end of file + run: make go-test + + go-tests-windows: + runs-on: windows-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: go test -v ./... -timeout=15m -parallel=4 \ No newline at end of file diff --git a/config/config.go b/config/config.go index 96764ad..4fb1233 100644 --- a/config/config.go +++ b/config/config.go @@ -122,7 +122,7 @@ func (l *LXD) GetInstanceType() LXDImageType { func (l *LXD) Validate() error { if l.UnixSocket != "" { if _, err := os.Stat(l.UnixSocket); err != nil { - return fmt.Errorf("could not access unix socket %s: %q", l.UnixSocket, err) + return fmt.Errorf("could not access unix socket %s: %w", l.UnixSocket, err) } return nil @@ -146,16 +146,16 @@ func (l *LXD) Validate() error { } if _, err := os.Stat(l.ClientCertificate); err != nil { - return fmt.Errorf("failed to access client certificate %s: %q", l.ClientCertificate, err) + return fmt.Errorf("failed to access client certificate %s: %w", l.ClientCertificate, err) } if _, err := os.Stat(l.ClientKey); err != nil { - return fmt.Errorf("failed to access client key %s: %q", l.ClientKey, err) + return fmt.Errorf("failed to access client key %s: %w", l.ClientKey, err) } if l.TLSServerCert != "" { if _, err := os.Stat(l.TLSServerCert); err != nil { - return fmt.Errorf("failed to access tls_server_certificate %s: %q", l.TLSServerCert, err) + return fmt.Errorf("failed to access tls_server_certificate %s: %w", l.TLSServerCert, err) } } diff --git a/config/lxd_test.go b/config/lxd_test.go index d0ceba8..f614ae0 100644 --- a/config/lxd_test.go +++ b/config/lxd_test.go @@ -6,6 +6,7 @@ package config import ( + "os" "testing" "github.com/stretchr/testify/require" @@ -83,7 +84,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: \"CreateFile bogus unix socket: The system cannot find the file specified.\"") + require.ErrorIs(t, err, os.ErrNotExist) } func TestMissingUnixSocketAndMissingURL(t *testing.T) { @@ -134,14 +135,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: \"CreateFile /i/am/not/here: The system cannot find the path specified.\"") + require.ErrorIs(t, err, os.ErrNotExist) 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: \"CreateFile /me/neither: The system cannot find the path specified.\"") + require.ErrorIs(t, err, os.ErrNotExist) } func TestLXDInvalidServerCertPath(t *testing.T) { @@ -150,7 +151,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: \"CreateFile /not/a/valid/server/cert/path: The system cannot find the path specified.\"") + require.ErrorIs(t, err, os.ErrNotExist) } func TestInvalidLXDImageRemotes(t *testing.T) {