From e96876e6c7c3bcc9266998432b78531a75e569d5 Mon Sep 17 00:00:00 2001 From: thomas-senechal Date: Thu, 21 Dec 2023 13:40:16 +0100 Subject: [PATCH] Fix lint errors --- int/api/websites/all.go | 1 + int/api/websites/my.go | 1 + int/api/websites/prepare.go | 1 + int/api/websites/upload.go | 1 + int/api/websites/uploadMissed.go | 1 + int/configuration/configuration_test.go | 3 +- int/configuration/configuration_unix_test.go | 3 +- .../configuration_windows_test.go | 2 +- main.go | 10 ++-- pkg/certificate/certificate_test.go | 14 +++--- pkg/certificate/pem_test.go | 20 ++++---- pkg/certificate/store/store_darwin_test.go | 4 +- pkg/certstore/store_windows_test.go | 50 +++++++++---------- pkg/logger/level_test.go | 5 +- pkg/node/sendoperation/convert.go | 3 +- pkg/node/sendoperation/sendoperation.go | 1 + pkg/node/sendoperation/sendoperation_test.go | 25 +++++----- .../serializeaddress/serializeaddress_test.go | 3 +- pkg/nss/certutilservice_unix_test.go | 10 ++-- pkg/nss/manager_test.go | 9 ++-- pkg/plugin/plugin_test.go | 5 +- 21 files changed, 93 insertions(+), 79 deletions(-) diff --git a/int/api/websites/all.go b/int/api/websites/all.go index f7c8f8f0d..41bdabe19 100644 --- a/int/api/websites/all.go +++ b/int/api/websites/all.go @@ -36,6 +36,7 @@ func (h *registryHandler) Handle(_ operations.AllDomainsGetterParams) middleware //nolint:revive return utils.NewGoneResponder() + //nolint:govet results, err := Registry(h.config) if err != nil { return operations.NewMyDomainsGetterInternalServerError(). diff --git a/int/api/websites/my.go b/int/api/websites/my.go index 454610d94..71a7595b4 100644 --- a/int/api/websites/my.go +++ b/int/api/websites/my.go @@ -22,6 +22,7 @@ func (h *domainsHandler) Handle(params operations.MyDomainsGetterParams) middlew //nolint:revive return utils.NewGoneResponder() + //nolint:govet client := node.NewClient(h.config.NodeURL) myDomainNames, err := my.Domains(*h.config, client, params.Nickname) diff --git a/int/api/websites/prepare.go b/int/api/websites/prepare.go index f3b433a36..adb04f3ce 100644 --- a/int/api/websites/prepare.go +++ b/int/api/websites/prepare.go @@ -43,6 +43,7 @@ func (h *websitePrepare) Handle(params operations.WebsiteUploaderPrepareParams) //nolint:revive return utils.NewGoneResponder() + //nolint:govet archive, errorResponse := readAndCheckArchive(params.Zipfile) if errorResponse != nil { return errorResponse diff --git a/int/api/websites/upload.go b/int/api/websites/upload.go index da20bf470..c5dd9ffbe 100644 --- a/int/api/websites/upload.go +++ b/int/api/websites/upload.go @@ -22,6 +22,7 @@ func (h *websiteUploadHandler) Handle(params operations.WebsiteUploaderUploadPar //nolint:revive return utils.NewGoneResponder() + //nolint:govet archive, errorResponse := readAndCheckArchive(params.Zipfile) if errorResponse != nil { return errorResponse diff --git a/int/api/websites/uploadMissed.go b/int/api/websites/uploadMissed.go index ba4a689e6..a7008f5a1 100644 --- a/int/api/websites/uploadMissed.go +++ b/int/api/websites/uploadMissed.go @@ -22,6 +22,7 @@ func (h *uploadMissedChunkHandler) Handle(params operations.WebsiteUploadMissing //nolint:revive return utils.NewGoneResponder() + //nolint:govet archive, errorResponse := readAndCheckArchive(params.Zipfile) if errorResponse != nil { return errorResponse diff --git a/int/configuration/configuration_test.go b/int/configuration/configuration_test.go index c58450a54..2e7d8b31e 100644 --- a/int/configuration/configuration_test.go +++ b/int/configuration/configuration_test.go @@ -4,6 +4,7 @@ import ( "testing" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" ) func TestPath_MASSAHOME(t *testing.T) { @@ -12,6 +13,6 @@ func TestPath_MASSAHOME(t *testing.T) { t.Setenv("MASSA_HOME", wantedPath) path, err := Path() - assert.NoError(t, err) + require.NoError(t, err) assert.Equal(t, wantedPath, path) } diff --git a/int/configuration/configuration_unix_test.go b/int/configuration/configuration_unix_test.go index 96d2210cb..46bdfaf0a 100644 --- a/int/configuration/configuration_unix_test.go +++ b/int/configuration/configuration_unix_test.go @@ -7,10 +7,11 @@ import ( "testing" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" ) func TestPath_Unix(t *testing.T) { path, err := Path() - assert.NoError(t, err) + require.NoError(t, err) assert.Equal(t, "/usr/local/share/massastation", path) } diff --git a/int/configuration/configuration_windows_test.go b/int/configuration/configuration_windows_test.go index 618997f25..301520407 100644 --- a/int/configuration/configuration_windows_test.go +++ b/int/configuration/configuration_windows_test.go @@ -18,6 +18,6 @@ func TestPath_Windows(t *testing.T) { expectedPath = filepath.Dir(expectedPath) path, err := Path() - assert.NoError(t, err) + require.NoError(t, err) assert.Equal(t, expectedPath, path) } diff --git a/main.go b/main.go index 47de54bc7..5e6301a5c 100644 --- a/main.go +++ b/main.go @@ -3,7 +3,6 @@ package main import ( "context" "embed" - "flag" "fmt" "log" @@ -21,6 +20,7 @@ import ( ) //go:embed all:web/massastation/dist +//nolint:nolintlint,typecheck var assets embed.FS type StartFlags struct { @@ -97,13 +97,13 @@ func main() { // Create application with options err = wails.Run(&options.App{ Title: "Massa Station", - Width: 1280, - Height: 720, + Width: 1280, //nolint:gomnd + Height: 720, //nolint:gomnd AssetServer: &assetserver.Options{ Assets: assets, }, OnStartup: func(ctx context.Context) { - server.Start(networkManager, pluginManager) + server.Start(networkManager, pluginManager) //nolint:contextcheck err := pluginManager.RunAll() if err != nil { logger.Fatalf("while running all plugins: %w", err) @@ -116,6 +116,6 @@ func main() { }) if err != nil { - println("Error:", err.Error()) + logger.Errorf("error while running wails: %s", err.Error()) } } diff --git a/pkg/certificate/certificate_test.go b/pkg/certificate/certificate_test.go index 6ca3078b9..cba69be10 100644 --- a/pkg/certificate/certificate_test.go +++ b/pkg/certificate/certificate_test.go @@ -3,7 +3,7 @@ package certificate import ( "testing" - "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" ) func TestReadFile(t *testing.T) { @@ -21,9 +21,9 @@ func TestReadFile(t *testing.T) { t.Run(tt.name, func(t *testing.T) { _, err := readFile(tt.filepath) if tt.wantErr { - assert.Error(t, err) + require.Error(t, err) } else { - assert.NoError(t, err) + require.NoError(t, err) } }) } @@ -45,9 +45,9 @@ func TestLoadCertificate(t *testing.T) { t.Run(tt.name, func(t *testing.T) { _, err := LoadCertificate(tt.filepath) if tt.wantErr { - assert.Error(t, err) + require.Error(t, err) } else { - assert.NoError(t, err) + require.NoError(t, err) } }) } @@ -69,9 +69,9 @@ func TestLoadPrivateKey(t *testing.T) { t.Run(tt.name, func(t *testing.T) { _, err := LoadPrivateKey(tt.filepath) if tt.wantErr { - assert.Error(t, err) + require.Error(t, err) } else { - assert.NoError(t, err) + require.NoError(t, err) } }) } diff --git a/pkg/certificate/pem_test.go b/pkg/certificate/pem_test.go index 2a3cb15af..33b04fb01 100644 --- a/pkg/certificate/pem_test.go +++ b/pkg/certificate/pem_test.go @@ -3,7 +3,7 @@ package certificate import ( "testing" - "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" ) const ( @@ -48,9 +48,9 @@ func TestDecodePEM(t *testing.T) { t.Run(tt.name, func(t *testing.T) { _, err := DecodePEM([]byte(tt.data)) if tt.wantErr { - assert.Error(t, err) + require.Error(t, err) } else { - assert.NoError(t, err) + require.NoError(t, err) } }) } @@ -105,9 +105,9 @@ func TestDecodeExpectedPEM(t *testing.T) { t.Run(tt.name, func(t *testing.T) { _, err := DecodeExpectedPEM([]byte(tt.data), tt.expected) if tt.wantErr { - assert.Error(t, err) + require.Error(t, err) } else { - assert.NoError(t, err) + require.NoError(t, err) } }) } @@ -153,7 +153,7 @@ func TestPemTypeIsValid(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - assert.Equal(t, tt.want, tt.p.IsValid()) + require.Equal(t, tt.want, tt.p.IsValid()) }) } } @@ -198,7 +198,7 @@ func TestPemTypeString(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - assert.Equal(t, tt.want, tt.p.String()) + require.Equal(t, tt.want, tt.p.String()) }) } } @@ -250,12 +250,12 @@ func TestNewPemType(t *testing.T) { t.Run(test.name, func(t *testing.T) { got, err := NewPemType(test.args.str) if test.wantErr { - assert.Error(t, err) + require.Error(t, err) } else { - assert.NoError(t, err) + require.NoError(t, err) } - assert.Equal(t, test.want, got) + require.Equal(t, test.want, got) }) } } diff --git a/pkg/certificate/store/store_darwin_test.go b/pkg/certificate/store/store_darwin_test.go index 961755548..ceba4a088 100644 --- a/pkg/certificate/store/store_darwin_test.go +++ b/pkg/certificate/store/store_darwin_test.go @@ -5,7 +5,7 @@ import ( "testing" "github.com/massalabs/station/pkg/certificate" - "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" ) func TestManualCheck(t *testing.T) { @@ -25,5 +25,5 @@ func TestManualCheck(t *testing.T) { } err = Add(cert) - assert.NoError(t, err) + require.NoError(t, err) } diff --git a/pkg/certstore/store_windows_test.go b/pkg/certstore/store_windows_test.go index ea49b3f0c..3647e3dbd 100644 --- a/pkg/certstore/store_windows_test.go +++ b/pkg/certstore/store_windows_test.go @@ -112,10 +112,10 @@ func TestCertStore_AddCertificate(t *testing.T) { err := store.AddCertificate(cert) if tt.wantErr != nil { - assert.Error(t, err) - assert.ErrorIs(t, err, tt.wantErr) + require.Error(t, err) + require.ErrorIs(t, err, tt.wantErr) } else { - assert.NoError(t, err) + require.NoError(t, err) } }) } @@ -190,10 +190,10 @@ func TestCertStore_RemoveCertificate(t *testing.T) { err := store.RemoveCertificate(cert) if tt.wantErr != nil { - assert.Error(t, err) - assert.ErrorIs(t, err, tt.wantErr) + require.Error(t, err) + require.ErrorIs(t, err, tt.wantErr) } else { - assert.NoError(t, err) + require.NoError(t, err) } }) } @@ -281,10 +281,10 @@ func TestCertStore_FetchCertificates(t *testing.T) { certPool, err := store.FetchCertificates() if tt.wantErr != nil { - assert.Error(t, err) - assert.ErrorIs(t, err, tt.wantErr) + require.Error(t, err) + require.ErrorIs(t, err, tt.wantErr) } else { - assert.NoError(t, err) + require.NoError(t, err) assert.Len(t, certPool.Subjects(), tt.poolLength) } }) @@ -304,7 +304,7 @@ func TestCertStore_Close(t *testing.T) { } err := store.Close(false) - assert.NoError(t, err) + require.NoError(t, err) }) t.Run("checkNonFreedCtx is true", func(t *testing.T) { @@ -316,7 +316,7 @@ func TestCertStore_Close(t *testing.T) { mockAPI.EXPECT().CertCloseStore(windows.Handle(1), uint32(windows.CERT_CLOSE_STORE_CHECK_FLAG)).Return(nil) err := store.Close(true) - assert.NoError(t, err) + require.NoError(t, err) }) t.Run("checkNonFreedCtx is false", func(t *testing.T) { @@ -328,7 +328,7 @@ func TestCertStore_Close(t *testing.T) { mockAPI.EXPECT().CertCloseStore(windows.Handle(1), uint32(0)).Return(nil) err := store.Close(false) - assert.NoError(t, err) + require.NoError(t, err) }) } @@ -342,7 +342,7 @@ func TestNewCertStore(t *testing.T) { mockAPI.EXPECT().UTF16PtrFromString("testStore").Return(nil, errors.New("conversion error")) _, err := NewCertStore(mockAPI, "testStore") - assert.Error(t, err) + require.Error(t, err) assert.Contains(t, err.Error(), "unable to convert store name to UTF16") }) @@ -351,7 +351,7 @@ func TestNewCertStore(t *testing.T) { mockAPI.EXPECT().CertOpenSystemStore(windows.Handle(0), gomock.Any()).Return(windows.Handle(0), errors.New("store opening error")) _, err := NewCertStore(mockAPI, "testStore") - assert.Error(t, err) + require.Error(t, err) assert.Contains(t, err.Error(), "unable to open system certificate store") }) @@ -360,7 +360,7 @@ func TestNewCertStore(t *testing.T) { mockAPI.EXPECT().CertOpenSystemStore(windows.Handle(0), gomock.Any()).Return(windows.Handle(1), nil) store, err := NewCertStore(mockAPI, "testStore") - assert.NoError(t, err) + require.NoError(t, err) assert.NotNil(t, store) assert.Equal(t, windows.Handle(1), store.handler) }) @@ -417,13 +417,13 @@ func TestInterpretError(t *testing.T) { if tc.expected != nil { // shall match // the expected error - assert.ErrorIs(t, actual, tc.expected) + require.ErrorIs(t, actual, tc.expected) // the initial error - assert.ErrorAs(t, actual, &tc.err) + require.ErrorAs(t, actual, &tc.err) // the expected error string assert.EqualError(t, actual, tc.errStr) } else { - assert.NoError(t, actual) + require.NoError(t, actual) } }) } @@ -436,32 +436,32 @@ func TestManualCheck(t *testing.T) { // Initialize the certificate store. store, err := NewCertStore(NewWindowsImpl(), RootStore) - assert.NoError(t, err) + require.NoError(t, err) // Add the certificate to the store. err = store.AddCertificate(cert) - assert.NoError(t, err) + require.NoError(t, err) // Check that the added certificate is in the list. pool, err := store.FetchCertificates() - assert.NoError(t, err) + require.NoError(t, err) assert.True(t, certInPool(cert, pool)) // Delete the added certificate. err = store.RemoveCertificate(cert) - assert.NoError(t, err) + require.NoError(t, err) // Check that the deleted certificate is no longer in the list. pool, err = store.FetchCertificates() - assert.NoError(t, err) + require.NoError(t, err) assert.False(t, certInPool(cert, pool)) // Delete a non existing certificate and verify that there is an error. err = store.RemoveCertificate(cert) - assert.Error(t, err) + require.Error(t, err) // Close the store checking for non freed context. // This is needed to avoid memory leaks. err = store.Close(true) - assert.NoError(t, err) + require.NoError(t, err) } diff --git a/pkg/logger/level_test.go b/pkg/logger/level_test.go index 9965bd6e4..bd9e379d1 100644 --- a/pkg/logger/level_test.go +++ b/pkg/logger/level_test.go @@ -4,6 +4,7 @@ import ( "testing" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" ) func TestLogLevel(t *testing.T) { @@ -26,9 +27,9 @@ func TestLogLevel(t *testing.T) { got, err := LogLevel() if tt.wantErr { - assert.Error(t, err) + require.Error(t, err) } else { - assert.NoError(t, err) + require.NoError(t, err) } assert.Equal(t, tt.want, got) diff --git a/pkg/node/sendoperation/convert.go b/pkg/node/sendoperation/convert.go index 39c131b98..0a4751457 100644 --- a/pkg/node/sendoperation/convert.go +++ b/pkg/node/sendoperation/convert.go @@ -2,6 +2,7 @@ package sendoperation import ( "fmt" + "strconv" "github.com/shopspring/decimal" ) @@ -9,7 +10,7 @@ import ( const MasDecimals = 9 func NanoToMas(nanoMasAmount uint64) (string, error) { - dec, err := decimal.NewFromString(fmt.Sprint(nanoMasAmount)) + dec, err := decimal.NewFromString(strconv.FormatUint(nanoMasAmount, 10)) if err != nil { return "", fmt.Errorf("converting '%d' to decimal: %w", nanoMasAmount, err) } diff --git a/pkg/node/sendoperation/sendoperation.go b/pkg/node/sendoperation/sendoperation.go index 44821d37e..f7b9a6a17 100644 --- a/pkg/node/sendoperation/sendoperation.go +++ b/pkg/node/sendoperation/sendoperation.go @@ -77,6 +77,7 @@ func Call(client *node.Client, var content string + //nolint:goconst switch { case operationBatch.NewBatch: content = `{ diff --git a/pkg/node/sendoperation/sendoperation_test.go b/pkg/node/sendoperation/sendoperation_test.go index ec60b489b..97a387d3d 100644 --- a/pkg/node/sendoperation/sendoperation_test.go +++ b/pkg/node/sendoperation/sendoperation_test.go @@ -10,6 +10,7 @@ import ( "github.com/massalabs/station/pkg/node/sendoperation/sellrolls" "github.com/massalabs/station/pkg/node/sendoperation/transaction" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" ) const ( @@ -47,7 +48,7 @@ func TestSerializeDeserializeCallSCMessage(t *testing.T) { // Create a new CallSC operation operation, err := callsc.New(testcase.address, testcase.function, testcase.parameters, testcase.maxGas, testcase.coins) - assert.NoError(err, "Failed to create CallSC operation") + require.NoError(t, err, "Failed to create CallSC operation") // Serialize the operation msg := message(testcase.expiry, testcase.fee, operation) @@ -55,14 +56,14 @@ func TestSerializeDeserializeCallSCMessage(t *testing.T) { // Simulate decoding and deserialization decodedMsg, fee, expiry, err := DecodeMessage64(msgB64) - assert.NoError(err, "Error decoding message") + require.NoError(t, err, "Error decoding message") // verify the fee and expiry assert.Equal(testcase.fee, fee, "fee mismatch") assert.Equal(testcase.expiry, expiry, "expiry mismatch") callSC, err := callsc.DecodeMessage(decodedMsg) - assert.NoError(err, "Error decoding CallSC") + require.NoError(t, err, "Error decoding CallSC") // Verify the fields assert.Equal(CallSCOpType, callSC.OperationType, "Operation type mismatch") @@ -101,14 +102,14 @@ func TestSerializeDeserializeExecuteSCMessage(t *testing.T) { // Simulate decoding and deserialization decodedMsg, fee, expiry, err := DecodeMessage64(msgB64) - assert.NoError(err, "Error decoding message") + require.NoError(t, err, "Error decoding message") // verify the fee and expiry assert.Equal(testCase.fee, fee, "fee mismatch") assert.Equal(testCase.expiry, expiry, "expiry mismatch") executeSC, err := executesc.DecodeMessage(decodedMsg) - assert.NoError(err, "Error decoding ExecuteSC") + require.NoError(t, err, "Error decoding ExecuteSC") // Verify the fields assert.Equal(ExecuteSCOpType, executeSC.OperationType, "Operation type mismatch") @@ -134,7 +135,7 @@ func TestSerializeDeserializeBuyRollsMessage(t *testing.T) { // Simulate decoding and deserialization buyRolls, err := RollDecodeMessage(operation.Message()) - assert.NoError(err, "Error decoding BuyRolls") + require.NoError(t, err, "Error decoding BuyRolls") // Verify the countRolls field assert.Equal(BuyRollOpType, buyRolls.OperationType, "Operation type mismatch") @@ -159,7 +160,7 @@ func TestSerializeDeserializeSellRollsMessage(t *testing.T) { // Simulate decoding and deserialization sellRolls, err := RollDecodeMessage(operation.Message()) - assert.NoError(err, "Error decoding SellRolls") + require.NoError(t, err, "Error decoding SellRolls") // Verify the countRolls field assert.Equal(SellRollOpType, sellRolls.OperationType, "Operation type mismatch") @@ -183,14 +184,14 @@ func TestSerializeDeserializeTransactionMessage(t *testing.T) { for _, testCase := range testCases { // Create a new Transaction myTx, err := transaction.New(testCase.recipientAddress, testCase.amount) - assert.NoError(err, "Failed to create Transaction") + require.NoError(t, err, "Failed to create Transaction") decodedOpType, err := DecodeOperationType(myTx.Message()) - assert.NoError(err, "Failed to retrieve operationID") + require.NoError(t, err, "Failed to retrieve operationID") // Simulate decoding and deserialization decodedTransaction, err := transaction.DecodeMessage(myTx.Message()) - assert.NoError(err, "Error decoding message") + require.NoError(t, err, "Error decoding message") // Verify the fields assert.Equal(TransactionOpType, decodedOpType, "Operation type mismatch") @@ -227,9 +228,9 @@ func TestDecodeOperationID(t *testing.T) { for _, testCase := range testCases { decodedID, err := DecodeOperationType(testCase.msg) if testCase.expectedErr { - assert.Error(err, "Expected error") + require.Error(t, err, "Expected error") } else { - assert.NoError(err, "Unexpected error") + require.NoError(t, err, "Unexpected error") assert.Equal(testCase.expectedID, decodedID, "Operation ID mismatch") } } diff --git a/pkg/node/sendoperation/serializeaddress/serializeaddress_test.go b/pkg/node/sendoperation/serializeaddress/serializeaddress_test.go index 54d13f649..e5583a18d 100644 --- a/pkg/node/sendoperation/serializeaddress/serializeaddress_test.go +++ b/pkg/node/sendoperation/serializeaddress/serializeaddress_test.go @@ -4,6 +4,7 @@ import ( "testing" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" ) func TestSerializeAddress(t *testing.T) { @@ -84,7 +85,7 @@ func TestDeserializeAddress(t *testing.T) { for _, testCase := range testCases { address, err := DeserializeAddress(testCase.versionedAddress) - assert.NoError(t, err, "Received an unexpected error for versioned address %v", testCase.versionedAddress) + require.NoError(t, err, "Received an unexpected error for versioned address %v", testCase.versionedAddress) assert.Equal(t, testCase.expectedAddress, address, "Address mismatch for versioned address %v", testCase.versionedAddress) } diff --git a/pkg/nss/certutilservice_unix_test.go b/pkg/nss/certutilservice_unix_test.go index ef707a434..587554f65 100644 --- a/pkg/nss/certutilservice_unix_test.go +++ b/pkg/nss/certutilservice_unix_test.go @@ -4,7 +4,7 @@ import ( "os" "testing" - "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" ) // TestCertUtilService_AddCA tests the AddCA method of CertUtilService. @@ -29,17 +29,17 @@ func TestCertUtilService_AddCA(t *testing.T) { // Adding the certificate. err = service.AddCA(dbPath, certName, certPath) - assert.NoError(t, err) + require.NoError(t, err) // Verifying the certificate is present. err = service.IsKnownCA(dbPath, certName) - assert.NoError(t, err) + require.NoError(t, err) // Removing the certificate. err = service.DeleteCA(dbPath, certName) - assert.NoError(t, err) + require.NoError(t, err) // Verifying the certificate is no longer present. err = service.IsKnownCA(dbPath, certName) - assert.Error(t, err) + require.Error(t, err) } diff --git a/pkg/nss/manager_test.go b/pkg/nss/manager_test.go index f5087ba78..1e675f1e3 100644 --- a/pkg/nss/manager_test.go +++ b/pkg/nss/manager_test.go @@ -7,6 +7,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" + "github.com/stretchr/testify/require" ) // MockCertUtilServicer is a mock of CertUtilServicer. @@ -58,7 +59,7 @@ func TestManager_AddCA(t *testing.T) { err := m.AddCA("testCert", "/path/to/cert") - assert.NoError(t, err) + require.NoError(t, err) mockCertUtilServicer.AssertExpectations(t) mockLogger.AssertExpectations(t) } @@ -73,7 +74,7 @@ func TestManager_DeleteCA(t *testing.T) { err := m.DeleteCA("testCert") - assert.NoError(t, err) + require.NoError(t, err) mockCertUtilServicer.AssertExpectations(t) mockLogger.AssertExpectations(t) } @@ -103,7 +104,7 @@ func TestManager_AddCA_Error(t *testing.T) { err := m.AddCA("testCert", "/path/to/cert") - assert.Error(t, err) + require.Error(t, err) mockCertUtilServicer.AssertExpectations(t) mockLogger.AssertExpectations(t) } @@ -118,7 +119,7 @@ func TestManager_DeleteCA_Error(t *testing.T) { err := m.DeleteCA("testCert") - assert.Error(t, err) + require.Error(t, err) mockCertUtilServicer.AssertExpectations(t) mockLogger.AssertExpectations(t) } diff --git a/pkg/plugin/plugin_test.go b/pkg/plugin/plugin_test.go index c042e6d2c..87d10e155 100644 --- a/pkg/plugin/plugin_test.go +++ b/pkg/plugin/plugin_test.go @@ -6,6 +6,7 @@ import ( "github.com/massalabs/station/int/config" "github.com/massalabs/station/pkg/store" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" ) type testPluginUpdate struct { @@ -31,14 +32,14 @@ func AssertUpdate(t *testing.T, testPluginUpdate testPluginUpdate) { config.Version = testPluginUpdate.massaStationVersion pluginCompatible, err := pluginInStore.IsPluginCompatible() - assert.NoError(t, err) + require.NoError(t, err) pluginInStore.IsCompatible = pluginCompatible assert.Equal(t, pluginCompatible, testPluginUpdate.compatible) storeMS.Plugins[0].IsCompatible = pluginCompatible isUpdatable, err := storeMS.CheckForPluginUpdates(plgn.info.Name, plgn.info.Version) - assert.NoError(t, err) + require.NoError(t, err) assert.Equal(t, isUpdatable, testPluginUpdate.updatable) }