From f207af4eaaf5591f0c8f8967c3a3b7796444b4d2 Mon Sep 17 00:00:00 2001 From: Lukasz Marchewka Date: Fri, 30 Jan 2026 09:39:04 +0100 Subject: [PATCH] STAC-24232 Rename stackpack `test` command to `test-deploy` --- cmd/stackpack.go | 2 +- ...st_cmd.go => stackpack_test_deploy_cmd.go} | 34 +++++++++---------- ...t.go => stackpack_test_deploy_cmd_test.go} | 22 ++++++------ cmd/stackpack_test.go | 2 +- 4 files changed, 30 insertions(+), 30 deletions(-) rename cmd/stackpack/{stackpack_test_cmd.go => stackpack_test_deploy_cmd.go} (94%) rename cmd/stackpack/{stackpack_test_cmd_test.go => stackpack_test_deploy_cmd_test.go} (94%) diff --git a/cmd/stackpack.go b/cmd/stackpack.go index a2eb0db5..0f7fc83f 100644 --- a/cmd/stackpack.go +++ b/cmd/stackpack.go @@ -32,7 +32,7 @@ func StackPackCommand(cli *di.Deps) *cobra.Command { if os.Getenv(experimentalStackpackEnvVar) != "" { cmd.AddCommand(stackpack.StackpackScaffoldCommand(cli)) cmd.AddCommand(stackpack.StackpackPackageCommand(cli)) - cmd.AddCommand(stackpack.StackpackTestCommand(cli)) + cmd.AddCommand(stackpack.StackpackTestDeployCommand(cli)) } return cmd diff --git a/cmd/stackpack/stackpack_test_cmd.go b/cmd/stackpack/stackpack_test_deploy_cmd.go similarity index 94% rename from cmd/stackpack/stackpack_test_cmd.go rename to cmd/stackpack/stackpack_test_deploy_cmd.go index 6aa391d8..d6999a3d 100644 --- a/cmd/stackpack/stackpack_test_cmd.go +++ b/cmd/stackpack/stackpack_test_deploy_cmd.go @@ -21,21 +21,21 @@ const ( stackpackConfigFile = "stackpack.yaml" ) -// TestArgs contains arguments for stackpack test command -type TestArgs struct { +// TestDeployArgs contains arguments for stackpack test-deploy command +type TestDeployArgs struct { StackpackDir string Params map[string]string Yes bool UnlockedStrategy string } -// StackpackTestCommand creates the test subcommand -func StackpackTestCommand(cli *di.Deps) *cobra.Command { - args := &TestArgs{ +// StackpackTestDeployCommand creates the test-deploy subcommand +func StackpackTestDeployCommand(cli *di.Deps) *cobra.Command { + args := &TestDeployArgs{ Params: make(map[string]string), } cmd := &cobra.Command{ - Use: "test", + Use: "test-deploy", Short: "Test a stackpack by packaging, uploading, and installing/upgrading", Long: `Test a stackpack by running package, upload, and install/upgrade commands in sequence. @@ -50,17 +50,17 @@ This command will: The original stackpack directory is left untouched. The version is automatically incremented for each test run. The stackpack name is read from ` + stackpackConfigFile + `, so no --name flag is required.`, Example: `# Test stackpack with confirmation -sts stackpack test -p "param1=value1" +sts stackpack test-deploy -p "param1=value1" # Skip confirmation prompt -sts stackpack test --yes +sts stackpack test-deploy --yes # Test stackpack in specific directory with unlocked strategy -sts stackpack test -d ./my-stackpack --yes --unlocked-strategy force +sts stackpack test-deploy -d ./my-stackpack --yes --unlocked-strategy force # Test with custom unlocked strategy -sts stackpack test --unlocked-strategy skip --yes`, - RunE: cli.CmdRunEWithApi(RunStackpackTestCommand(args)), +sts stackpack test-deploy --unlocked-strategy skip --yes`, + RunE: cli.CmdRunEWithApi(RunStackpackTestDeployCommand(args)), } cmd.Flags().StringVarP(&args.StackpackDir, "stackpack-directory", "d", "", "Path to stackpack directory (defaults to current directory)") @@ -71,19 +71,19 @@ sts stackpack test --unlocked-strategy skip --yes`, return cmd } -// RunStackpackTestCommand executes the test command +// RunStackpackTestDeployCommand executes the test-deploy command // //nolint:funlen -func RunStackpackTestCommand(args *TestArgs) di.CmdWithApiFn { +func RunStackpackTestDeployCommand(args *TestDeployArgs) di.CmdWithApiFn { return func( cmd *cobra.Command, cli *di.Deps, api *stackstate_api.APIClient, serverInfo *stackstate_api.ServerInfo, ) common.CLIError { - // Warn if JSON output is requested - not meaningful for test command + // Warn if JSON output is requested - not meaningful for test-deploy command if cli.IsJson() { - cli.Printer.PrintLn("Warning: JSON output format is not meaningful for the test command, proceeding with text output") + cli.Printer.PrintLn("Warning: JSON output format is not meaningful for the test-deploy command, proceeding with text output") } // Set default stackpack directory @@ -103,7 +103,7 @@ func RunStackpackTestCommand(args *TestArgs) di.CmdWithApiFn { return common.NewRuntimeError(fmt.Errorf("failed to parse %s: %w", stackpackConfigFile, err)) } - cli.Printer.Success("Starting stackpack test sequence...") + cli.Printer.Success("Starting stackpack test-deploy sequence...") cli.Printer.PrintLn(fmt.Sprintf(" Stackpack: %s (current version: %s)", originalInfo.Name, originalInfo.Version)) cli.Printer.PrintLn("") @@ -239,7 +239,7 @@ func RunStackpackTestCommand(args *TestArgs) di.CmdWithApiFn { } cli.Printer.PrintLn("") - cli.Printer.Success("🎉 Test sequence completed successfully!") + cli.Printer.Success("🎉 Test-deploy sequence completed successfully!") // Clean up .sts file if err := os.Remove(packageArgs.ArchiveFile); err != nil { diff --git a/cmd/stackpack/stackpack_test_cmd_test.go b/cmd/stackpack/stackpack_test_deploy_cmd_test.go similarity index 94% rename from cmd/stackpack/stackpack_test_cmd_test.go rename to cmd/stackpack/stackpack_test_deploy_cmd_test.go index 7a0308c3..764785f3 100644 --- a/cmd/stackpack/stackpack_test_cmd_test.go +++ b/cmd/stackpack/stackpack_test_deploy_cmd_test.go @@ -14,18 +14,18 @@ import ( "github.com/stretchr/testify/require" ) -// setupStackpackTestCmd creates a test command with mock dependencies -func setupStackpackTestCmd(t *testing.T) (*di.MockDeps, *cobra.Command) { +// setupStackpackTestDeployCmd creates a test command with mock dependencies +func setupStackpackTestDeployCmd(t *testing.T) (*di.MockDeps, *cobra.Command) { cli := di.NewMockDeps(t) - cmd := StackpackTestCommand(&cli.Deps) + cmd := StackpackTestDeployCommand(&cli.Deps) return &cli, cmd } -func TestStackpackTestCommand_FlagsAndStructure(t *testing.T) { - _, cmd := setupStackpackTestCmd(t) +func TestStackpackTestDeployCommand_FlagsAndStructure(t *testing.T) { + _, cmd := setupStackpackTestDeployCmd(t) // Test command structure - assert.Equal(t, "test", cmd.Use) + assert.Equal(t, "test-deploy", cmd.Use) assert.Contains(t, cmd.Short, "Test a stackpack") assert.Contains(t, cmd.Long, "package, upload, and install") assert.NotEmpty(t, cmd.Example) @@ -163,7 +163,7 @@ func TestCopyDirectory(t *testing.T) { assert.Equal(t, testContent, string(copiedContent2)) } -func TestStackpackTestCommand_RequiredFlags(t *testing.T) { +func TestStackpackTestDeployCommand_RequiredFlags(t *testing.T) { tests := []struct { name string args []string @@ -184,7 +184,7 @@ func TestStackpackTestCommand_RequiredFlags(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - cli, cmd := setupStackpackTestCmd(t) + cli, cmd := setupStackpackTestDeployCmd(t) _, err := di.ExecuteCommandWithContext(&cli.Deps, cmd, tt.args...) if tt.wantErr { @@ -202,7 +202,7 @@ func TestStackpackTestCommand_RequiredFlags(t *testing.T) { } } -func TestStackpackTestCommand_DirectoryHandling(t *testing.T) { +func TestStackpackTestDeployCommand_DirectoryHandling(t *testing.T) { // Create temporary directory with valid stackpack structure tempDir, err := os.MkdirTemp("", "stackpack-test-dir-*") require.NoError(t, err) @@ -214,7 +214,7 @@ func TestStackpackTestCommand_DirectoryHandling(t *testing.T) { // Create required files createTestStackpack(t, stackpackDir, "test-stackpack", "1.0.0") - cli, cmd := setupStackpackTestCmd(t) + cli, cmd := setupStackpackTestDeployCmd(t) tests := []struct { name string @@ -384,7 +384,7 @@ func TestCompareVersionsSemver(t *testing.T) { } } -func TestStackpackTestCommand_InstallUpgradeLogic(t *testing.T) { +func TestStackpackTestDeployCommand_InstallUpgradeLogic(t *testing.T) { tests := []struct { name string installedVersion string diff --git a/cmd/stackpack_test.go b/cmd/stackpack_test.go index 2d58cf70..3a3e7daa 100644 --- a/cmd/stackpack_test.go +++ b/cmd/stackpack_test.go @@ -42,7 +42,7 @@ func TestStackPackCommand_FeatureGating(t *testing.T) { }, } - experimentalCommands := []string{"scaffold", "package", "test"} + experimentalCommands := []string{"scaffold", "package", "test-deploy"} for _, tt := range tests { t.Run(tt.name, func(t *testing.T) {