-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathhelp_test.go
More file actions
124 lines (101 loc) · 4.36 KB
/
help_test.go
File metadata and controls
124 lines (101 loc) · 4.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
//go:build integration
package integration
import (
"fmt"
"io"
"strings"
"testing"
"gotest.tools/assert"
)
// 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(
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 <command> <subcommand> [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 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")
}
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")
}