@@ -20,38 +20,37 @@ func TestHelpCommand(t *testing.T) {
2020 output , err := RunCommand (slog , "oc-netobserv" , "help" )
2121 assert .Nil (t , err )
2222
23- err = os .WriteFile (path .Join ("output" , StartupDate + "-helpOutput" ), output , 0666 )
23+ err = os .WriteFile (path .Join ("output" , StartupDate + "-helpOutput" ), [] byte ( output ) , 0666 )
2424 assert .Nil (t , err )
2525
26- str := string (output )
27- assert .NotEmpty (t , str )
26+ assert .NotEmpty (t , output )
2827 // ensure help display overall description
29- assert .Contains (t , str , "Netobserv allows you to capture flows, packets and metrics from your cluster." )
30- assert .Contains (t , str , "Find more information at: https://github.com/netobserv/network-observability-cli/" )
28+ assert .Contains (t , output , "Netobserv allows you to capture flows, packets and metrics from your cluster." )
29+ assert .Contains (t , output , "Find more information at: https://github.com/netobserv/network-observability-cli/" )
3130 // ensure help to display main commands
32- assert .Contains (t , str , "main commands:" )
33- assert .Contains (t , str , "Syntax: netobserv [flows|packets|metrics|follow|stop|copy|cleanup|version] [options]" )
34- assert .Contains (t , str , "flows Capture flows information in JSON format using collector pod." )
35- assert .Contains (t , str , "metrics Capture metrics information in Prometheus using a ServiceMonitor (OCP cluster only)." )
36- assert .Contains (t , str , "packets Capture packets information in pcap format using collector pod." )
31+ assert .Contains (t , output , "main commands:" )
32+ assert .Contains (t , output , "Syntax: netobserv [flows|packets|metrics|follow|stop|copy|cleanup|version] [options]" )
33+ assert .Contains (t , output , "flows Capture flows information in JSON format using collector pod." )
34+ assert .Contains (t , output , "metrics Capture metrics information in Prometheus using a ServiceMonitor (OCP cluster only)." )
35+ assert .Contains (t , output , "packets Capture packets information in pcap format using collector pod." )
3736 // ensure help to display extra commands
38- assert .Contains (t , str , "extra commands:" )
39- assert .Contains (t , str , "cleanup Remove netobserv components and configurations." )
40- assert .Contains (t , str , "copy Copy collector generated files locally." )
41- assert .Contains (t , str , "follow Follow collector logs when running in background." )
42- assert .Contains (t , str , "stop Stop collection by removing agent daemonset." )
43- assert .Contains (t , str , "version Print software version." )
37+ assert .Contains (t , output , "extra commands:" )
38+ assert .Contains (t , output , "cleanup Remove netobserv components and configurations." )
39+ assert .Contains (t , output , "copy Copy collector generated files locally." )
40+ assert .Contains (t , output , "follow Follow collector logs when running in background." )
41+ assert .Contains (t , output , "stop Stop collection by removing agent daemonset." )
42+ assert .Contains (t , output , "version Print software version." )
4443 // ensure help to display examples
45- assert .Contains (t , str , "basic examples:" )
46- assert .Contains (t , str , "netobserv flows --drops # Capture dropped flows on all nodes" )
47- assert .Contains (t , str , "netobserv flows --query='SrcK8S_Namespace=~\" app-.*\" ' # Capture flows from any namespace starting by app-" )
48- assert .Contains (t , str , "netobserv packets --port=8080 # Capture packets on port 8080" )
49- assert .Contains (t , str , "netobserv metrics --enable_all # Capture default cluster metrics including packet drop, dns, rtt, network events packet translation and UDN mapping features informations" )
50- assert .Contains (t , str , "advanced examples:" )
51- assert .Contains (t , str , "Capture flows in background and copy output locally" )
52- assert .Contains (t , str , "Capture flows from a specific pod" )
53- assert .Contains (t , str , "Capture packets on specific nodes and port" )
54- assert .Contains (t , str , "Capture node and namespace drop metrics" )
44+ assert .Contains (t , output , "basic examples:" )
45+ assert .Contains (t , output , "netobserv flows --drops # Capture dropped flows on all nodes" )
46+ assert .Contains (t , output , "netobserv flows --query='SrcK8S_Namespace=~\" app-.*\" ' # Capture flows from any namespace starting by app-" )
47+ assert .Contains (t , output , "netobserv packets --port=8080 # Capture packets on port 8080" )
48+ assert .Contains (t , output , "netobserv metrics --enable_all # Capture default cluster metrics including packet drop, dns, rtt, network events packet translation and UDN mapping features informations" )
49+ assert .Contains (t , output , "advanced examples:" )
50+ assert .Contains (t , output , "Capture flows in background and copy output locally" )
51+ assert .Contains (t , output , "Capture flows from a specific pod" )
52+ assert .Contains (t , output , "Capture packets on specific nodes and port" )
53+ assert .Contains (t , output , "Capture node and namespace drop metrics" )
5554
5655 })
5756}
@@ -61,12 +60,11 @@ func TestVersionCommand(t *testing.T) {
6160 output , err := RunCommand (slog , "oc-netobserv" , "version" )
6261 assert .Nil (t , err )
6362
64- err = os .WriteFile (path .Join ("output" , StartupDate + "-versionOutput" ), output , 0666 )
63+ err = os .WriteFile (path .Join ("output" , StartupDate + "-versionOutput" ), [] byte ( output ) , 0666 )
6564 assert .Nil (t , err )
6665
67- str := string (output )
68- assert .NotEmpty (t , str )
66+ assert .NotEmpty (t , output )
6967 // ensure version display test
70- assert .Contains (t , str , "Netobserv CLI version test" )
68+ assert .Contains (t , output , "Netobserv CLI version test" )
7169 })
7270}
0 commit comments