Skip to content

Commit b30f3fa

Browse files
authored
Command empty strings (#839)
* Added ctx object to all system struct's constructors The idea behind this commit is to set the stage for adding aditional logging metadata. * Changed: Improved logging * Added new flags `--log-level` and `-l` to be consistent with other goss flags. * `--loglevel` and `-L` will be deprecated in a future release * Log level accepts any casing, so DEBUG and debug are both valid cli opts * Add log level support for `add` and `autoadd` commands * Changed: Goss add command default to empty string Changed the behavior of `goss add` on a command, if the value of stdout or stderr is empty, it will be defaulted to an empty string instead of an empty array. The behavior remains unchanged when there is output; the value will be an array. This approach provides the following benefits: * Tests will fail if an empty string receives a value. * Arrays allows for simpler deletion of lines that are not relevant to the test assertion. closes #820 * fix build error
1 parent b1ffb25 commit b30f3fa

File tree

11 files changed

+54
-48
lines changed

11 files changed

+54
-48
lines changed

integration-tests/goss/alpine3/goss-expected-q.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ package:
1313
vim-tiny:
1414
installed: false
1515
addr:
16-
tcp://google.com:22:
16+
tcp://httpbin:22:
1717
reachable: false
1818
timeout: 1000
19-
tcp://google.com:443:
19+
tcp://httpbin:80:
2020
reachable: true
2121
timeout: 1000
2222
udp://8.8.8.8:53:
@@ -49,13 +49,13 @@ group:
4949
command:
5050
echo 'hi':
5151
exit-status: 0
52-
stdout: []
53-
stderr: []
52+
stdout: ""
53+
stderr: ""
5454
timeout: 10000
5555
foobar:
5656
exit-status: 127
57-
stdout: []
58-
stderr: []
57+
stdout: ""
58+
stderr: ""
5959
timeout: 10000
6060
dns:
6161
CAA:dnstest.io:

integration-tests/goss/alpine3/goss-expected.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ package:
1919
vim-tiny:
2020
installed: false
2121
addr:
22-
tcp://google.com:22:
22+
tcp://httpbin:22:
2323
reachable: false
2424
timeout: 1000
25-
tcp://google.com:443:
25+
tcp://httpbin:80:
2626
reachable: true
2727
timeout: 1000
2828
udp://8.8.8.8:53:
@@ -62,11 +62,11 @@ command:
6262
exit-status: 0
6363
stdout:
6464
- hi
65-
stderr: []
65+
stderr: ""
6666
timeout: 10000
6767
foobar:
6868
exit-status: 127
69-
stdout: []
69+
stdout: ""
7070
stderr:
7171
- 'sh: foobar: not found'
7272
timeout: 10000

integration-tests/goss/centos7/goss-expected-q.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ package:
1313
vim-tiny:
1414
installed: false
1515
addr:
16-
tcp://google.com:22:
16+
tcp://httpbin:22:
1717
reachable: false
1818
timeout: 1000
19-
tcp://google.com:443:
19+
tcp://httpbin:80:
2020
reachable: true
2121
timeout: 1000
2222
udp://8.8.8.8:53:
@@ -49,13 +49,13 @@ group:
4949
command:
5050
echo 'hi':
5151
exit-status: 0
52-
stdout: []
53-
stderr: []
52+
stdout: ""
53+
stderr: ""
5454
timeout: 10000
5555
foobar:
5656
exit-status: 127
57-
stdout: []
58-
stderr: []
57+
stdout: ""
58+
stderr: ""
5959
timeout: 10000
6060
dns:
6161
CAA:dnstest.io:

integration-tests/goss/centos7/goss-expected.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ package:
1919
vim-tiny:
2020
installed: false
2121
addr:
22-
tcp://google.com:22:
22+
tcp://httpbin:22:
2323
reachable: false
2424
timeout: 1000
25-
tcp://google.com:443:
25+
tcp://httpbin:80:
2626
reachable: true
2727
timeout: 1000
2828
udp://8.8.8.8:53:
@@ -68,11 +68,11 @@ command:
6868
exit-status: 0
6969
stdout:
7070
- hi
71-
stderr: []
71+
stderr: ""
7272
timeout: 10000
7373
foobar:
7474
exit-status: 127
75-
stdout: []
75+
stdout: ""
7676
stderr:
7777
- 'sh: foobar: command not found'
7878
timeout: 10000

integration-tests/goss/generate_goss.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ done
2222
[[ $OS == "centos7" ]] && user="apache" || user="www-data"
2323
goss a "${args[@]}" package $package foobar vim-tiny
2424

25-
goss a "${args[@]}" addr --timeout 1s google.com:443 google.com:22
25+
goss a "${args[@]}" addr --timeout 1s httpbin:80 httpbin:22
2626

2727
goss a "${args[@]}" addr --timeout 1s udp://8.8.8.8:53
2828

integration-tests/goss/goss-shared.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,13 @@ service:
7070
runlevels: {{toJson $runlevels}}
7171
{{end}}
7272
addr:
73-
tcp://google.com:22:
73+
tcp://httpbin:22:
7474
reachable: false
7575
timeout: 1000
76-
tcp://google.com:443:
76+
tcp://httpbin:80:
7777
reachable: true
7878
timeout: 5000
79-
tcp://google.com:80:
79+
tcp://httpbin:999:
8080
reachable: false
8181
timeout: 5000
8282
local-address: 127.0.0.1

integration-tests/goss/trusty/goss-expected-q.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ package:
1313
vim-tiny:
1414
installed: false
1515
addr:
16-
tcp://google.com:22:
16+
tcp://httpbin:22:
1717
reachable: false
1818
timeout: 1000
19-
tcp://google.com:443:
19+
tcp://httpbin:80:
2020
reachable: true
2121
timeout: 1000
2222
udp://8.8.8.8:53:
@@ -49,13 +49,13 @@ group:
4949
command:
5050
echo 'hi':
5151
exit-status: 0
52-
stdout: []
53-
stderr: []
52+
stdout: ""
53+
stderr: ""
5454
timeout: 10000
5555
foobar:
5656
exit-status: 127
57-
stdout: []
58-
stderr: []
57+
stdout: ""
58+
stderr: ""
5959
timeout: 10000
6060
dns:
6161
CAA:dnstest.io:

integration-tests/goss/trusty/goss-expected.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ package:
1919
vim-tiny:
2020
installed: false
2121
addr:
22-
tcp://google.com:22:
22+
tcp://httpbin:22:
2323
reachable: false
2424
timeout: 1000
25-
tcp://google.com:443:
25+
tcp://httpbin:80:
2626
reachable: true
2727
timeout: 1000
2828
udp://8.8.8.8:53:
@@ -68,11 +68,11 @@ command:
6868
exit-status: 0
6969
stdout:
7070
- hi
71-
stderr: []
71+
stderr: ""
7272
timeout: 10000
7373
foobar:
7474
exit-status: 127
75-
stdout: []
75+
stdout: ""
7676
stderr:
7777
- 'sh: 1: foobar: not found'
7878
timeout: 10000

integration-tests/goss/wheezy/goss-expected-q.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ package:
1313
vim-tiny:
1414
installed: false
1515
addr:
16-
tcp://google.com:22:
16+
tcp://httpbin:22:
1717
reachable: false
1818
timeout: 1000
19-
tcp://google.com:443:
19+
tcp://httpbin:80:
2020
reachable: true
2121
timeout: 1000
2222
udp://8.8.8.8:53:
@@ -49,13 +49,13 @@ group:
4949
command:
5050
echo 'hi':
5151
exit-status: 0
52-
stdout: []
53-
stderr: []
52+
stdout: ""
53+
stderr: ""
5454
timeout: 10000
5555
foobar:
5656
exit-status: 127
57-
stdout: []
58-
stderr: []
57+
stdout: ""
58+
stderr: ""
5959
timeout: 10000
6060
dns:
6161
CAA:dnstest.io:

integration-tests/goss/wheezy/goss-expected.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ package:
1919
vim-tiny:
2020
installed: false
2121
addr:
22-
tcp://google.com:22:
22+
tcp://httpbin:22:
2323
reachable: false
2424
timeout: 1000
25-
tcp://google.com:443:
25+
tcp://httpbin:80:
2626
reachable: true
2727
timeout: 1000
2828
udp://8.8.8.8:53:
@@ -68,11 +68,11 @@ command:
6868
exit-status: 0
6969
stdout:
7070
- hi
71-
stderr: []
71+
stderr: ""
7272
timeout: 10000
7373
foobar:
7474
exit-status: 127
75-
stdout: []
75+
stdout: ""
7676
stderr:
7777
- 'sh: 1: foobar: not found'
7878
timeout: 10000

0 commit comments

Comments
 (0)