Skip to content

Commit 335f923

Browse files
committed
Addressed linter issues
1 parent 0b604df commit 335f923

File tree

5 files changed

+16
-17
lines changed

5 files changed

+16
-17
lines changed

internal/cmd/cloud_login.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,10 @@ func (c *cmdCloudLogin) run(cmd *cobra.Command, _ []string) error {
103103
return nil
104104
case tokenInput.Valid || stackInput.Valid:
105105
if !stackInput.Valid || stackInput.String == "" {
106-
return errors.New("Stack value is required but it was not passed or is empty")
106+
return errors.New("stack value is required but it was not passed or is empty")
107107
}
108108
if !tokenInput.Valid || tokenInput.String == "" {
109-
return errors.New("Token value is required but it was not passed or is empty")
109+
return errors.New("token value is required but it was not passed or is empty")
110110
}
111111
err := authenticateUserToken(c.globalState, &newCloudConf, currentJSONConfigRaw, tokenInput.String, stackInput.String)
112112
if err != nil {
@@ -179,7 +179,7 @@ func promptUserAuthForm(gs *state.GlobalState) (userAuthForm, error) {
179179
}
180180
token := strings.TrimSpace(tokenVals["Token"])
181181
if token == "" {
182-
return userAuthForm{}, errors.New("Token cannot be empty")
182+
return userAuthForm{}, errors.New("token cannot be empty")
183183
}
184184

185185
/* Stack form */
@@ -199,7 +199,7 @@ func promptUserAuthForm(gs *state.GlobalState) (userAuthForm, error) {
199199
}
200200
stack := strings.TrimSpace(stackVals["Stack"])
201201
if stack == "" {
202-
return userAuthForm{}, errors.New("Stack cannot be empty")
202+
return userAuthForm{}, errors.New("stack cannot be empty")
203203
}
204204

205205
return userAuthForm{token: token, stack: stack}, nil
@@ -254,7 +254,7 @@ func authenticateUserToken(
254254
stackURL, stackID, defaultProjectID, err := validateTokenV6(
255255
gs, consolidatedCurrentConfig, token, stack)
256256
if err != nil {
257-
return fmt.Errorf(
257+
return fmt.Errorf( //nolint:staticcheck // ST1005: this is a user-facing error
258258
"Authentication failed as provided token or stack might not be valid."+
259259
" Learn more: https://grafana.com/docs/grafana-cloud/testing/k6/author-run/tokens-and-cli-authentication."+
260260
" Server error for details: %w",

internal/cmd/outputs_cloud.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const (
3333
// and to populate the Cloud configuration back in case the Cloud API returned some overrides,
3434
// as expected by the Cloud output.
3535
//
36-
//nolint:funlen,gocognit,cyclop
36+
//nolint:funlen
3737
func createCloudTest(gs *state.GlobalState, test *loadedAndConfiguredTest) error {
3838
// Otherwise, we continue normally with the creation of the test run in the k6 Cloud backend services.
3939
conf, warn, err := cloudapi.GetConsolidatedConfig(

internal/cmd/tests/cmd_cloud_login_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,15 @@ func TestCloudLoginWithArgs(t *testing.T) {
4848
token: validToken,
4949
wantErr: true,
5050
wantStdoutContains: []string{
51-
"Stack value is required",
51+
"stack value is required",
5252
},
5353
},
5454
{
5555
name: "valid stack without token fails",
5656
stack: validStack,
5757
wantErr: true,
5858
wantStdoutContains: []string{
59-
"Token value is required",
59+
"token value is required",
6060
},
6161
},
6262
{

internal/cmd/tests/cmd_cloud_run_test.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ export const options = {
8888
8989
export default function() {};`
9090

91-
ts := makeTestState(t, script, []string{"--local-execution"}, 0)
91+
ts := makeTestState(t, script, []string{"--local-execution"})
9292

9393
testServerHandlerFunc := http.HandlerFunc(func(resp http.ResponseWriter, req *http.Request) {
9494
// When using the local execution mode, the test archive should be uploaded to the cloud
@@ -141,7 +141,7 @@ export const options = {
141141
142142
export default function() {};`
143143

144-
ts := makeTestState(t, script, []string{"--local-execution", "--no-archive-upload"}, 0)
144+
ts := makeTestState(t, script, []string{"--local-execution", "--no-archive-upload"})
145145

146146
testServerHandlerFunc := http.HandlerFunc(func(resp http.ResponseWriter, req *http.Request) {
147147
body, err := io.ReadAll(req.Body)
@@ -198,7 +198,7 @@ export default function() {
198198
` + "console.log(`The test run id is ${__ENV.K6_CLOUDRUN_TEST_RUN_ID}`);" + `
199199
};`
200200

201-
ts := makeTestState(t, script, []string{"--local-execution", "--log-output=stdout"}, 0)
201+
ts := makeTestState(t, script, []string{"--local-execution", "--log-output=stdout"})
202202

203203
const testRunID = 1337
204204
srv := getCloudTestEndChecker(t, testRunID, nil, cloudapi.RunStatusFinished, cloudapi.ResultStatusPassed)
@@ -226,7 +226,7 @@ export const options = {
226226
227227
export default function() {};`
228228

229-
ts := makeTestState(t, script, []string{"--local-execution", "--log-output=stdout"}, 0)
229+
ts := makeTestState(t, script, []string{"--local-execution", "--log-output=stdout"})
230230
ts.ExpectedExitCode = -1
231231
delete(ts.Env, "K6_CLOUD_STACK_ID")
232232

@@ -238,15 +238,14 @@ export default function() {};`
238238
})
239239
}
240240

241-
func makeTestState(tb testing.TB, script string, cliFlags []string, expExitCode exitcodes.ExitCode) *GlobalTestState {
241+
func makeTestState(tb testing.TB, script string, cliFlags []string) *GlobalTestState {
242242
if cliFlags == nil {
243243
cliFlags = []string{"-v", "--log-output=stdout"}
244244
}
245245

246246
ts := NewGlobalTestState(tb)
247247
require.NoError(tb, fsext.WriteFile(ts.FS, filepath.Join(ts.Cwd, "test.js"), []byte(script), 0o644))
248248
ts.CmdArgs = append(append([]string{"k6", "cloud", "run"}, cliFlags...), "test.js")
249-
ts.ExpectedExitCode = int(expExitCode)
250249
ts.Env["K6_CLOUD_TOKEN"] = "foo" // doesn't matter, we mock the cloud
251250
ts.Env["K6_CLOUD_STACK_ID"] = "1234" // doesn't matter, we mock the cloud
252251

internal/cmd/tests/cmd_cloud_upload_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,10 @@ func TestK6CloudUpload(t *testing.T) {
133133
require.NoError(t, fsext.WriteFile(ts.FS, filepath.Join(ts.Cwd, "archive.tar"), data, 0o644))
134134

135135
ts.CmdArgs = []string{"k6", "cloud", "upload", "archive.tar"}
136-
ts.Env["K6_SHOW_CLOUD_LOGS"] = "false" // no mock for the logs yet
136+
ts.Env["K6_SHOW_CLOUD_LOGS"] = "false" // no mock for the logs yet
137137
ts.Env["K6_CLOUD_HOST"] = srv.URL
138-
ts.Env["K6_CLOUD_TOKEN"] = "foo" // doesn't matter, we mock the cloud
139-
ts.Env["K6_CLOUD_STACK_ID"] = "1234" // doesn't matter, we mock the cloud
138+
ts.Env["K6_CLOUD_TOKEN"] = "foo"
139+
ts.Env["K6_CLOUD_STACK_ID"] = "1234"
140140

141141
cmd.ExecuteWithGlobalState(ts.GlobalState)
142142

0 commit comments

Comments
 (0)