From ebcfa4e36a67485b831daffd86387e0a223dcebc Mon Sep 17 00:00:00 2001 From: Dhanashree Wani Date: Tue, 7 Oct 2025 10:59:11 +0530 Subject: [PATCH 1/2] help command tests --- test/integration/help_test.go | 78 +++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 test/integration/help_test.go diff --git a/test/integration/help_test.go b/test/integration/help_test.go new file mode 100644 index 000000000..feef63b68 --- /dev/null +++ b/test/integration/help_test.go @@ -0,0 +1,78 @@ +//go:build integration + +package integration + +import ( + "fmt" + "io" + "strings" + "testing" + + "gotest.tools/assert" +) + +// verify cx --help +// verify cx project --help +// verify cx scan --help +func TestCxRootHelpCommand(t *testing.T) { + // Capture the output of the help command + buffer := executeCmdNilAssertion( + t, + "--help", + ) + + // Read the output + result, err := io.ReadAll(buffer) + assert.NilError(t, err, "Reading help command output should succeed") + + // Convert output to string and check for expected content + output := string(result) + fmt.Println("Help output:\n", output) + + assert.Assert(t, strings.Contains(output, "The Checkmarx One CLI is a fully functional Command Line Interface (CLI) that interacts with the Checkmarx One server")) + assert.Assert(t, strings.Contains(output, "cx [flags]")) +} + +func TestProjectHelpCommand(t *testing.T) { + // Capture the output of the help command + buffer := executeCmdNilAssertion( + t, + "The help command for 'project' should execute successfully", + "project", "--help", + ) + + // Read the output + result, err := io.ReadAll(buffer) + assert.NilError(t, err, "Reading help command output should succeed") + + // Convert output to string and check for expected content + output := string(result) + fmt.Println("Help project output:\n", output) + + // Assert it contains some expected help output + assert.Assert(t, strings.Contains(output, "The project command enables the ability to manage projects in Checkmarx One"), "Help output should contain command description") + assert.Assert(t, strings.Contains(output, "cx project [flags]"), "Help output should contain usage information") + assert.Assert(t, strings.Contains(output, "COMMANDS"), "Help output should list available COMMANDS") +} + +func TestScanHelpCommand(t *testing.T) { + // Capture the output of the help command + buffer := executeCmdNilAssertion( + t, + "The help command for 'scan' should execute successfully", + "scan", "--help", + ) + + // Read the output + result, err := io.ReadAll(buffer) + assert.NilError(t, err, "Reading help command output should succeed") + + // Convert output to string and check for expected content + output := string(result) + fmt.Println("Help scan output:\n", output) + + // Assert it contains some expected help output + assert.Assert(t, strings.Contains(output, "The scan command enables the ability to manage scans in Checkmarx One"), "Help output should contain command description") + assert.Assert(t, strings.Contains(output, "cx scan [flags]"), "Help output should contain usage information") + assert.Assert(t, strings.Contains(output, "COMMANDS"), "Help output should list available COMMANDS") +} From 4fa5eabc9ade160a03b4f0c0ba868101322d0709 Mon Sep 17 00:00:00 2001 From: Dhanashree Wani Date: Tue, 7 Oct 2025 11:23:54 +0530 Subject: [PATCH 2/2] Added triage and results help --- test/integration/help_test.go | 48 ++++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/test/integration/help_test.go b/test/integration/help_test.go index feef63b68..ee3cead6a 100644 --- a/test/integration/help_test.go +++ b/test/integration/help_test.go @@ -14,6 +14,8 @@ import ( // verify cx --help // verify cx project --help // verify cx scan --help +// verify cx triage --help +// verify cx results --help func TestCxRootHelpCommand(t *testing.T) { // Capture the output of the help command buffer := executeCmdNilAssertion( @@ -49,7 +51,7 @@ func TestProjectHelpCommand(t *testing.T) { output := string(result) fmt.Println("Help project output:\n", output) - // Assert it contains some expected help output + // Assert it contains expected help output assert.Assert(t, strings.Contains(output, "The project command enables the ability to manage projects in Checkmarx One"), "Help output should contain command description") assert.Assert(t, strings.Contains(output, "cx project [flags]"), "Help output should contain usage information") assert.Assert(t, strings.Contains(output, "COMMANDS"), "Help output should list available COMMANDS") @@ -76,3 +78,47 @@ func TestScanHelpCommand(t *testing.T) { assert.Assert(t, strings.Contains(output, "cx scan [flags]"), "Help output should contain usage information") assert.Assert(t, strings.Contains(output, "COMMANDS"), "Help output should list available COMMANDS") } + +func TestTriageHelpCommand(t *testing.T) { + // Capture the output of the help command + buffer := executeCmdNilAssertion( + t, + "The help command for 'triage' should execute successfully", + "triage", "--help", + ) + + // Read the output + result, err := io.ReadAll(buffer) + assert.NilError(t, err, "Reading help command output should succeed") + + // Convert output to string and check for expected content + output := string(result) + fmt.Println("Help triage output:\n", output) + + // Assert it contains expected help output + assert.Assert(t, strings.Contains(output, "The 'triage' command enables the ability to manage results in Checkmarx One"), "Help output should contain command description") + assert.Assert(t, strings.Contains(output, "cx triage [flags]"), "Help output should contain usage information") + assert.Assert(t, strings.Contains(output, "COMMANDS"), "Help output should list available COMMANDS") +} + +func TestResultsHelpCommand(t *testing.T) { + // Capture the output of the help command + buffer := executeCmdNilAssertion( + t, + "The help command for 'results' should execute successfully", + "results", "--help", + ) + + // Read the output + result, err := io.ReadAll(buffer) + assert.NilError(t, err, "Reading help command output should succeed") + + // Convert output to string and check for expected content + output := string(result) + fmt.Println("Help results output:\n", output) + + // Assert it contains expected help output + assert.Assert(t, strings.Contains(output, "Retrieve results"), "Help output should contain command description") + assert.Assert(t, strings.Contains(output, "cx results [flags]"), "Help output should contain usage information") + assert.Assert(t, strings.Contains(output, "COMMANDS"), "Help output should list available COMMANDS") +}