Skip to content

Commit 473f762

Browse files
committed
Migrated a few additional tests
1 parent d864201 commit 473f762

3 files changed

Lines changed: 13 additions & 13 deletions

File tree

internal/cmd/cloud_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,15 +148,15 @@ func TestCheckCloudLogin(t *testing.T) {
148148
conf: cloudapi.Config{
149149
Token: null.StringFrom("valid-token"),
150150
},
151-
wantErr: errStackNotConfigured,
151+
wantErr: errUserUnauthenticated,
152152
},
153153
{
154154
name: "zero stack ID returns stack not configured error",
155155
conf: cloudapi.Config{
156156
Token: null.StringFrom("valid-token"),
157157
StackID: null.IntFrom(0),
158158
},
159-
wantErr: errStackNotConfigured,
159+
wantErr: errUserUnauthenticated,
160160
},
161161
}
162162

internal/cmd/tests/cmd_cloud_run_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ export default function() {};`
234234

235235
stdout := ts.Stdout.String()
236236
t.Log(stdout)
237-
assert.Contains(t, stdout, "stack must be configured")
237+
assert.Contains(t, stdout, "must first authenticate")
238238
})
239239
}
240240

@@ -247,8 +247,8 @@ func makeTestState(tb testing.TB, script string, cliFlags []string, expExitCode
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")
249249
ts.ExpectedExitCode = int(expExitCode)
250-
ts.Env["K6_CLOUD_TOKEN"] = "foo" // doesn't matter, we mock the cloud
251-
ts.Env["K6_CLOUD_STACK_ID"] = "1234" // doesn't matter, we mock the cloud
250+
ts.Env["K6_CLOUD_TOKEN"] = "foo" // doesn't matter, we mock the cloud
251+
ts.Env["K6_CLOUD_STACK_ID"] = "1234" // doesn't matter, we mock the cloud
252252

253253
return ts
254254
}

internal/cmd/tests/cmd_cloud_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ func runCloudTests(t *testing.T, setupCmd setupCommandFunc) {
5555

5656
stdout := ts.Stdout.String()
5757
t.Log(stdout)
58-
assert.Contains(t, stdout, `stack must be configured`)
58+
assert.Contains(t, stdout, `must first authenticate`)
5959
})
6060

6161
t.Run("TestCloudLoggedInWithScriptToken", func(t *testing.T) {
@@ -209,10 +209,10 @@ func runCloudTests(t *testing.T, setupCmd setupCommandFunc) {
209209
require.NoError(t, fsext.WriteFile(ts.FS, filepath.Join(ts.Cwd, "archive.tar"), data, 0o644))
210210

211211
ts.CmdArgs = []string{"k6", "cloud", "--verbose", "--log-output=stdout", "archive.tar"}
212-
ts.Env["K6_SHOW_CLOUD_LOGS"] = "false" // no mock for the logs yet
212+
ts.Env["K6_SHOW_CLOUD_LOGS"] = "false" // no mock for the logs yet
213213
ts.Env["K6_CLOUD_HOST"] = srv.URL
214-
ts.Env["K6_CLOUD_TOKEN"] = "foo" // doesn't matter, we mock the cloud
215-
ts.Env["K6_CLOUD_STACK_ID"] = "1234" // doesn't matter, we mock the cloud
214+
ts.Env["K6_CLOUD_TOKEN"] = "foo" // doesn't matter, we mock the cloud
215+
ts.Env["K6_CLOUD_STACK_ID"] = "1234" // doesn't matter, we mock the cloud
216216

217217
cmd.ExecuteWithGlobalState(ts.GlobalState)
218218

@@ -331,11 +331,11 @@ func getSimpleCloudTestState(t *testing.T, script []byte, setupCmd setupCommandF
331331
ts := NewGlobalTestState(t)
332332
require.NoError(t, fsext.WriteFile(ts.FS, filepath.Join(ts.Cwd, "test.js"), script, 0o644))
333333
ts.CmdArgs = setupCmd(cliFlags)
334-
ts.Env["K6_SHOW_CLOUD_LOGS"] = "false" // no mock for the logs yet
334+
ts.Env["K6_SHOW_CLOUD_LOGS"] = "false" // no mock for the logs yet
335335
ts.Env["K6_CLOUD_HOST"] = srv.URL
336-
ts.Env["K6_CLOUD_TOKEN"] = "foo" // doesn't matter, we mock the cloud
337-
ts.Env["K6_CLOUD_STACK_ID"] = "1234" // doesn't matter, we mock the cloud
338-
ts.Env["K6_CLOUD_PROJECT_ID"] = "1234" // doesn't matter, we mock the cloud
336+
ts.Env["K6_CLOUD_TOKEN"] = "foo" // doesn't matter, we mock the cloud
337+
ts.Env["K6_CLOUD_STACK_ID"] = "1234" // doesn't matter, we mock the cloud
338+
ts.Env["K6_CLOUD_PROJECT_ID"] = "1234" // doesn't matter, we mock the cloud
339339

340340
return ts
341341
}

0 commit comments

Comments
 (0)