Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix CLI usage with no pre-set context/config #420

Merged
merged 12 commits into from
Sep 19, 2024
Prev Previous commit
Next Next commit
Remove test that's hard to isolate
tstirrat15 committed Sep 19, 2024
commit ddf0f6253661810bc7adf90215aff33c7e7c7f6d
16 changes: 0 additions & 16 deletions internal/client/client_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package client_test

Check failure on line 1 in internal/client/client_test.go

GitHub Actions / Lint Go

Please run gofumpt. diff --git a/internal/client/client_test.go b/internal/client/client_test.go index 5538b42..f68bf5d 100644 --- a/internal/client/client_test.go +++ b/internal/client/client_test.go @@ -104,7 +104,7 @@ func TestGetCurrentTokenWithCLIOverrideWithoutSecretFile(t *testing.T) { tmpDir, err := os.MkdirTemp("", "") require.NoError(err) configPath := path.Join(tmpDir, "config.json") - err = os.WriteFile(configPath, []byte("{}"), 0600) + err = os.WriteFile(configPath, []byte("{}"), 0o600) require.NoError(err) configStore := &storage.JSONConfigStore{ConfigPath: tmpDir}

import (
"os"
@@ -118,19 +118,3 @@
require.Equal("e1", token.Endpoint)
require.Equal(&bTrue, token.Insecure)
}

func TestGetCurrentTokenWithCLIOverrideWithInsufficientArgs (t *testing.T) {
// This is to ensure that insufficient args don't unintentionally validate.
require := require.New(t)
cmd := zedtesting.CreateTestCobraCommandWithFlagValue(t,
zedtesting.StringFlag{FlagName: "token", FlagValue: "", Changed: false},
zedtesting.StringFlag{FlagName: "endpoint", FlagValue: "e1", Changed: true},
zedtesting.StringFlag{FlagName: "certificate-path", FlagValue: "", Changed: false},
)

configStore, secretStore := client.DefaultStorage()
_, err := client.GetCurrentTokenWithCLIOverride(cmd, configStore, secretStore)

// cli args take precedence when defined
require.NoError(err)
}