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 cloud command not listed in k6 command's help text #3901

Merged
merged 2 commits into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions cmd/cloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -366,16 +366,15 @@ func getCmdCloud(gs *state.GlobalState) *cobra.Command {
cloudCmd := &cobra.Command{
Use: "cloud",
Short: "Run a test on the cloud",
Long: `Run a test in the Grafana Cloud k6.
Long: `The original behavior of the "k6 cloud" command described below is deprecated.
In future versions, the "cloud" command will only display a help text and will no longer run tests
in Grafana Cloud k6. To continue running tests in the cloud, please transition to using the "k6 cloud run" command.

Run a test in the Grafana Cloud k6.

This will archive test script(s), including all necessary resources, and execute the test in the Grafana Cloud k6
service. Be sure to run the "k6 cloud login" command prior to authenticate with Grafana Cloud k6.`,
Args: exactCloudArgs(),
Deprecated: `the k6 team is in the process of modifying and deprecating the "k6 cloud" command behavior.
In the future, the "cloud" command will only display a help text, instead of running tests in the Grafana Cloud k6.

To run tests in the cloud, users are now invited to migrate to the "k6 cloud run" command instead.
`,
Args: exactCloudArgs(),
PreRunE: c.preRun,
RunE: c.run,
Example: exampleText,
Expand Down
90 changes: 90 additions & 0 deletions cmd/root_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
package cmd

import (
"testing"

"github.com/stretchr/testify/assert"
"go.k6.io/k6/cmd/tests"
"go.k6.io/k6/errext/exitcodes"
)

func TestRootCommandHelpDisplayCommands(t *testing.T) {
t.Parallel()

testCases := []struct {
name string
extraArgs []string
wantExitCode exitcodes.ExitCode
wantStdoutContains string
wantStdoutNotContains string
}{
{
name: "should have archive command",
wantStdoutContains: " archive Create an archive",
},
{
name: "should have cloud command",
wantStdoutContains: " cloud Run a test on the cloud",
},
{
name: "should have completion command",
wantStdoutContains: " completion Generate the autocompletion script for the specified shell",
},
{
name: "should have help command",
wantStdoutContains: " help Help about any command",
},
{
name: "should have inspect command",
wantStdoutContains: " inspect Inspect a script or archive",
},
{
name: "should have new command",
wantStdoutContains: " new Create and initialize a new k6 script",
},
{
name: "should have pause command",
wantStdoutContains: " pause Pause a running test",
},
{
name: "should have resume command",
wantStdoutContains: " resume Resume a paused test",
},
{
name: "should have run command",
wantStdoutContains: " run Start a test",
},
{
name: "should have scale command",
wantStdoutContains: " scale Scale a running test",
},
{
name: "should have stats command",
wantStdoutContains: " stats Show test metrics",
},
{
name: "should have status command",
wantStdoutContains: " status Show test status",
},
{
name: "should have version command",
wantStdoutContains: " version Show application version",
},
}

for _, tc := range testCases {
tc := tc

t.Run(tc.name, func(t *testing.T) {
t.Parallel()

ts := tests.NewGlobalTestState(t)
ts.CmdArgs = []string{"k6", "help"}
newRootCommand(ts.GlobalState).execute()

if tc.wantStdoutContains != "" {
assert.Contains(t, ts.Stdout.String(), tc.wantStdoutContains)
}
})
}
}