diff --git a/client_test.go b/client_test.go index 321a7e25..4b25deb1 100644 --- a/client_test.go +++ b/client_test.go @@ -228,10 +228,10 @@ func TestOpenFiltered(t *testing.T) { defer cl.Close(context.Background()) want := []string{"tester3", "tester1", "tester2"} if diff := cmp.Diff(cl.GetMetadata().ProvidersAttempted, want); diff != "" { - t.Errorf(diff) + t.Errorf("diff: %s", diff) } want = []string{"tester1", "tester2", "tester3"} if diff := cmp.Diff(registryNames(cl.Registry.Drivers), want); diff != "" { - t.Errorf(diff) + t.Errorf("diff: %s", diff) } } diff --git a/go.mod b/go.mod index 256f980f..9466f20e 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/bmc-toolbox/bmclib/v2 -go 1.18 +go 1.23 require ( dario.cat/mergo v1.0.0 diff --git a/lint.mk b/lint.mk index d492cc70..09ba98fd 100644 --- a/lint.mk +++ b/lint.mk @@ -20,7 +20,7 @@ LINTERS := FIXERS := GOLANGCI_LINT_CONFIG := $(LINT_ROOT)/.golangci.yml -GOLANGCI_LINT_VERSION ?= v1.53.3 +GOLANGCI_LINT_VERSION ?= v1.61.0 GOLANGCI_LINT_BIN := $(LINT_ROOT)/out/linters/golangci-lint-$(GOLANGCI_LINT_VERSION)-$(LINT_ARCH) $(GOLANGCI_LINT_BIN): mkdir -p $(LINT_ROOT)/out/linters diff --git a/providers/asrockrack/asrockrack_test.go b/providers/asrockrack/asrockrack_test.go index 755207b7..ce9a1b3f 100644 --- a/providers/asrockrack/asrockrack_test.go +++ b/providers/asrockrack/asrockrack_test.go @@ -12,7 +12,7 @@ import ( func TestHttpLogin(t *testing.T) { err := aClient.httpsLogin(context.TODO()) if err != nil { - t.Errorf(err.Error()) + t.Errorf("login: %s", err.Error()) } assert.Equal(t, "l5L29IP7", aClient.loginSession.CSRFToken) @@ -21,30 +21,30 @@ func TestHttpLogin(t *testing.T) { func TestClose(t *testing.T) { err := aClient.httpsLogin(context.TODO()) if err != nil { - t.Errorf(err.Error()) + t.Errorf("login setup: %s", err.Error()) } err = aClient.httpsLogout(context.TODO()) if err != nil { - t.Errorf(err.Error()) + t.Errorf("logout: %s", err.Error()) } } func TestFirwmwareUpdateBMC(t *testing.T) { err := aClient.httpsLogin(context.TODO()) if err != nil { - t.Errorf(err.Error()) + t.Errorf("login: %s", err.Error()) } upgradeFile := "/tmp/dummy-E3C246D4I-NL_L0.01.00.ima" _, err = os.Create(upgradeFile) if err != nil { - t.Errorf(err.Error()) + t.Errorf("create file: %s", err.Error()) } fh, err := os.Open(upgradeFile) if err != nil { - t.Errorf(err.Error()) + t.Errorf("file open: %s", err.Error()) } defer fh.Close() @@ -53,6 +53,6 @@ func TestFirwmwareUpdateBMC(t *testing.T) { err = aClient.firmwareUploadBMC(ctx, fh) if err != nil { - t.Errorf(err.Error()) + t.Errorf("upload: %s", err.Error()) } } diff --git a/providers/asrockrack/helpers.go b/providers/asrockrack/helpers.go index 503bda88..7f693451 100644 --- a/providers/asrockrack/helpers.go +++ b/providers/asrockrack/helpers.go @@ -558,7 +558,7 @@ func (a *ASRockRack) httpsLogin(ctx context.Context) error { resp, statusCode, err := a.queryHTTPS(ctx, urlEndpoint, "POST", bytes.NewReader(payload), headers, 0) if err != nil { - return fmt.Errorf("Error logging in: " + err.Error()) + return errors.Wrap(err, "logging in") } if statusCode == 401 { @@ -568,7 +568,7 @@ func (a *ASRockRack) httpsLogin(ctx context.Context) error { // Unmarshal login session err = json.Unmarshal(resp, a.loginSession) if err != nil { - return fmt.Errorf("error unmarshalling response payload: " + err.Error()) + return errors.Wrap(err, "unmarshalling response payload") } return nil @@ -578,7 +578,7 @@ func (a *ASRockRack) httpsLogin(ctx context.Context) error { func (a *ASRockRack) httpsLogout(ctx context.Context) error { _, statusCode, err := a.queryHTTPS(ctx, "api/session", "DELETE", nil, nil, 0) if err != nil { - return fmt.Errorf("Error logging out: " + err.Error()) + return errors.Wrap(err, "logging out") } if statusCode != http.StatusOK { diff --git a/providers/asrockrack/helpers_test.go b/providers/asrockrack/helpers_test.go index 83752b75..88d41452 100644 --- a/providers/asrockrack/helpers_test.go +++ b/providers/asrockrack/helpers_test.go @@ -21,12 +21,12 @@ func Test_FirmwareInfo(t *testing.T) { err := aClient.httpsLogin(context.TODO()) if err != nil { - t.Errorf(err.Error()) + t.Errorf("login: %s", err.Error()) } fwInfo, err := aClient.firmwareInfo(context.TODO()) if err != nil { - t.Error(err.Error()) + t.Errorf("firmwareInfo: %s", err.Error()) } assert.Equal(t, expected, fwInfo) @@ -35,7 +35,7 @@ func Test_FirmwareInfo(t *testing.T) { func TestInventoryInfo(t *testing.T) { err := aClient.httpsLogin(context.TODO()) if err != nil { - t.Errorf(err.Error()) + t.Errorf("login: %s", err.Error()) } inventory, err := aClient.inventoryInfoE3C246D41D(context.TODO()) @@ -50,7 +50,7 @@ func TestInventoryInfo(t *testing.T) { func Test_fruInfo(t *testing.T) { err := aClient.httpsLogin(context.TODO()) if err != nil { - t.Errorf(err.Error()) + t.Errorf("login: %s", err.Error()) } frus, err := aClient.fruInfo(context.TODO()) @@ -64,7 +64,7 @@ func Test_fruInfo(t *testing.T) { func Test_sensors(t *testing.T) { err := aClient.httpsLogin(context.TODO()) if err != nil { - t.Errorf(err.Error()) + t.Errorf("login: %s", err.Error()) } sensors, err := aClient.sensors(context.TODO()) @@ -83,7 +83,7 @@ func Test_biosPOSTCode(t *testing.T) { err := aClient.httpsLogin(context.TODO()) if err != nil { - t.Errorf(err.Error()) + t.Errorf("login: %s", err.Error()) } info, err := aClient.postCodeInfo(context.TODO()) @@ -102,7 +102,7 @@ func Test_chassisStatus(t *testing.T) { err := aClient.httpsLogin(context.TODO()) if err != nil { - t.Errorf(err.Error()) + t.Errorf("login: %s", err.Error()) } info, err := aClient.chassisStatusInfo(context.TODO()) diff --git a/providers/asrockrack/user_test.go b/providers/asrockrack/user_test.go index dc4dd857..38d2a9b8 100644 --- a/providers/asrockrack/user_test.go +++ b/providers/asrockrack/user_test.go @@ -62,7 +62,7 @@ func Test_UserRead(t *testing.T) { err := aClient.httpsLogin(context.TODO()) if err != nil { - t.Errorf(err.Error()) + t.Errorf("login: %s", err.Error()) } users, err := aClient.UserRead(context.TODO()) @@ -159,7 +159,7 @@ func Test_UserUpdate(t *testing.T) { func Test_createUser(t *testing.T) { err := aClient.httpsLogin(context.TODO()) if err != nil { - t.Errorf(err.Error()) + t.Errorf("login: %s", err.Error()) } account := &UserAccount{ @@ -202,7 +202,7 @@ func Test_createUser(t *testing.T) { func Test_userAccounts(t *testing.T) { err := aClient.httpsLogin(context.TODO()) if err != nil { - t.Errorf(err.Error()) + t.Errorf("login: %s", err.Error()) } account0 := &UserAccount{