From f31f8f72dec1871f9d5d51ac63b33cd2cd96f123 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Fri, 31 Jan 2025 09:21:02 +0200 Subject: [PATCH] chore: address linting issues --- internal/commands/tokens/create.go | 2 +- internal/commands/tokens/create_test.go | 10 +++++----- internal/commands/tokens/delete_test.go | 9 +++------ internal/testutils/time.go | 4 ++-- 4 files changed, 11 insertions(+), 14 deletions(-) diff --git a/internal/commands/tokens/create.go b/internal/commands/tokens/create.go index c77a8892..3a62adc2 100644 --- a/internal/commands/tokens/create.go +++ b/internal/commands/tokens/create.go @@ -1,9 +1,9 @@ package tokens import ( + "fmt" "time" - "fmt" "github.com/UpCloudLtd/upcloud-cli/v3/internal/commands" "github.com/UpCloudLtd/upcloud-cli/v3/internal/output" "github.com/UpCloudLtd/upcloud-cli/v3/internal/ui" diff --git a/internal/commands/tokens/create_test.go b/internal/commands/tokens/create_test.go index 5ef2c0c4..fce413d2 100644 --- a/internal/commands/tokens/create_test.go +++ b/internal/commands/tokens/create_test.go @@ -2,6 +2,7 @@ package tokens import ( "testing" + "time" "github.com/UpCloudLtd/upcloud-cli/v3/internal/commands" "github.com/UpCloudLtd/upcloud-cli/v3/internal/config" @@ -12,7 +13,6 @@ import ( "github.com/UpCloudLtd/upcloud-go-api/v8/upcloud/request" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" - "time" ) func TestCreateToken(t *testing.T) { @@ -55,7 +55,7 @@ func TestCreateToken(t *testing.T) { args: []string{ "--expires-in", "1h", }, - errFn: func(t assert.TestingT, err error, i ...interface{}) bool { + errFn: func(t assert.TestingT, err error, _ ...interface{}) bool { return assert.ErrorContains(t, err, `required flag(s) "name" not set`) }, }, @@ -65,7 +65,7 @@ func TestCreateToken(t *testing.T) { "--name", "test", "--expires-in", "seppo", }, - errFn: func(t assert.TestingT, err error, i ...interface{}) bool { + errFn: func(t assert.TestingT, err error, _ ...interface{}) bool { return assert.ErrorContains(t, err, `invalid argument "seppo" for "--expires-in"`) }, }, @@ -75,7 +75,7 @@ func TestCreateToken(t *testing.T) { "--name", "test", "--expires-at", "seppo", }, - errFn: func(t assert.TestingT, err error, i ...interface{}) bool { + errFn: func(t assert.TestingT, err error, _ ...interface{}) bool { return assert.ErrorContains(t, err, `invalid expires-at: `) }, }, @@ -84,7 +84,7 @@ func TestCreateToken(t *testing.T) { args: []string{ "--name", "test", }, - errFn: func(t assert.TestingT, err error, i ...interface{}) bool { + errFn: func(t assert.TestingT, err error, _ ...interface{}) bool { return assert.ErrorContains(t, err, `either expires-in or expires-at must be set`) }, }, diff --git a/internal/commands/tokens/delete_test.go b/internal/commands/tokens/delete_test.go index 87053fce..4f503f76 100644 --- a/internal/commands/tokens/delete_test.go +++ b/internal/commands/tokens/delete_test.go @@ -12,17 +12,14 @@ import ( ) func TestDeleteCommand(t *testing.T) { - tokenID := "0cdabbf9-090b-4fc5-a6ae-3f76801ed171" - svc := &smock.Service{} conf := config.New() + dr := &request.DeleteTokenRequest{ID: "0cdabbf9-090b-4fc5-a6ae-3f76801ed171"} - svc.On("DeleteToken", - &request.DeleteTokenRequest{ID: tokenID}, - ).Once().Return(nil) + svc.On("DeleteToken", dr).Once().Return(nil) command := commands.BuildCommand(DeleteCommand(), nil, conf) - _, err := command.(commands.MultipleArgumentCommand).Execute(commands.NewExecutor(conf, svc, flume.New("test")), tokenID) + _, err := command.(commands.MultipleArgumentCommand).Execute(commands.NewExecutor(conf, svc, flume.New("test")), dr.ID) assert.NoError(t, err) svc.AssertExpectations(t) diff --git a/internal/testutils/time.go b/internal/testutils/time.go index 417eacc9..5eb8f81c 100644 --- a/internal/testutils/time.go +++ b/internal/testutils/time.go @@ -1,10 +1,10 @@ package testutils import ( - "github.com/stretchr/testify/require" "testing" - "time" + + "github.com/stretchr/testify/require" ) func MustParseRFC3339(t *testing.T, timeStr string) *time.Time {