Skip to content

Commit

Permalink
build: Upgrade to go 1.21 and linter 1.54.2 (#599)
Browse files Browse the repository at this point in the history
Signed-off-by: Leonard Goodell <[email protected]>
  • Loading branch information
Lenny Goodell authored Sep 12, 2023
1 parent 1d77273 commit ff44a32
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ lint:
@if [ "z${ARCH}" = "zx86_64" ] && which golangci-lint >/dev/null ; then golangci-lint run --config .golangci.yml ; else echo "WARNING: Linting skipped (not on x86_64 or linter not installed)"; fi

install-lint:
sudo curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $$(go env GOPATH)/bin v1.51.2
sudo curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $$(go env GOPATH)/bin v1.54.2

test: unittest lint
$(GO) vet ./...
Expand Down
12 changes: 6 additions & 6 deletions bootstrap/handlers/messaging_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,15 @@ func TestBootstrapHandler(t *testing.T) {

tests := []struct {
Name string
MessageBus config.MessageBusInfo
MessageBus *config.MessageBusInfo
Secure bool
ExpectedResult bool
ExpectClient bool
}{
{"Valid secure - creates client", validCreateClientSecure, true, true, true},
{"Valid non-secure - creates client", validCreateClientNonSecure, false, true, true},
{"Invalid - secrets error", invalidSecrets, false, false, false},
{"Invalid - can't connect", invalidNoConnect, true, false, false},
{"Valid secure - creates client", &validCreateClientSecure, true, true, true},
{"Valid non-secure - creates client", &validCreateClientNonSecure, false, true, true},
{"Invalid - secrets error", &invalidSecrets, false, false, false},
{"Invalid - can't connect", &invalidNoConnect, true, false, false},
}

for _, test := range tests {
Expand All @@ -84,7 +84,7 @@ func TestBootstrapHandler(t *testing.T) {
providerMock.On("GetSecret", test.MessageBus.SecretName).Return(usernameSecretData, nil)
configMock := &mocks.Configuration{}
configMock.On("GetBootstrap").Return(config.BootstrapConfiguration{
MessageBus: &test.MessageBus,
MessageBus: test.MessageBus,
})

dic.Update(di.ServiceConstructorMap{
Expand Down
28 changes: 14 additions & 14 deletions bootstrap/messaging/messaging_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,43 +87,43 @@ func TestValidateSecrets(t *testing.T) {
Name string
SecureMode bool
AuthMode string
SecretData SecretData
SecretData *SecretData
ErrorExpectation bool
ErrorMessage string
}{
{"Invalid AuthMode", true, "BadAuthMode", SecretData{}, true, "Invalid AuthMode of 'BadAuthMode' selected"},
{"No Auth No error", true, AuthModeNone, SecretData{}, false, ""},
{"UsernamePassword No Error", true, AuthModeUsernamePassword, SecretData{
{"Invalid AuthMode", true, "BadAuthMode", &SecretData{}, true, "Invalid AuthMode of 'BadAuthMode' selected"},
{"No Auth No error", true, AuthModeNone, &SecretData{}, false, ""},
{"UsernamePassword No Error", true, AuthModeUsernamePassword, &SecretData{
Username: "user",
Password: "Password",
}, false, ""},
{"UsernamePassword Error no Username", true, AuthModeUsernamePassword, SecretData{
{"UsernamePassword Error no Username", true, AuthModeUsernamePassword, &SecretData{
Password: "Password",
}, true, "AuthModeUsernamePassword selected however Username or Password was not found for secret=unit-test"},
{"UsernamePassword blank - non-secure", false, AuthModeUsernamePassword, SecretData{
{"UsernamePassword blank - non-secure", false, AuthModeUsernamePassword, &SecretData{
Username: "",
Password: "",
}, false, ""},
{"UsernamePassword Error no Password", true, AuthModeUsernamePassword, SecretData{
{"UsernamePassword Error no Password", true, AuthModeUsernamePassword, &SecretData{
Username: "user",
}, true, "AuthModeUsernamePassword selected however Username or Password was not found for secret=unit-test"},
{"ClientCert No Error", true, AuthModeCert, SecretData{
{"ClientCert No Error", true, AuthModeCert, &SecretData{
CertPemBlock: []byte("----"),
KeyPemBlock: []byte("----"),
}, false, ""},
{"ClientCert No Key", true, AuthModeCert, SecretData{
{"ClientCert No Key", true, AuthModeCert, &SecretData{
CertPemBlock: []byte("----"),
}, true, "AuthModeCert selected however the key or cert PEM block was not found for secret=unit-test"},
{"ClientCert No Cert", true, AuthModeCert, SecretData{
{"ClientCert No Cert", true, AuthModeCert, &SecretData{
KeyPemBlock: []byte("----"),
}, true, "AuthModeCert selected however the key or cert PEM block was not found for secret=unit-test"},
{"CACert no error", true, AuthModeCA, SecretData{
{"CACert no error", true, AuthModeCA, &SecretData{
CaPemBlock: []byte(testCACert),
}, false, ""},
{"CACert invalid error", true, AuthModeCA, SecretData{
{"CACert invalid error", true, AuthModeCA, &SecretData{
CaPemBlock: []byte(`------`),
}, true, "Error parsing CA Certificate"},
{"CACert no ca error", true, AuthModeCA, SecretData{}, true, "AuthModeCA selected however no PEM Block was found for secret=unit-test"},
{"CACert no ca error", true, AuthModeCA, &SecretData{}, true, "AuthModeCA selected however no PEM Block was found for secret=unit-test"},
}

for _, test := range tests {
Expand All @@ -133,7 +133,7 @@ func TestValidateSecrets(t *testing.T) {
defer func() { _ = os.Setenv(secret.EnvSecretStore, "false") }()
}

result := ValidateSecretData(test.AuthMode, "unit-test", &test.SecretData)
result := ValidateSecretData(test.AuthMode, "unit-test", test.SecretData)
if test.ErrorExpectation {
require.Error(t, result, "Result should be an error")
assert.Equal(t, test.ErrorMessage, result.Error())
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/edgexfoundry/go-mod-bootstrap/v3

go 1.20
go 1.21

require (
github.com/eclipse/paho.mqtt.golang v1.4.3
Expand Down

0 comments on commit ff44a32

Please sign in to comment.