Skip to content

Commit 7e70e27

Browse files
authored
Update docs and output (#833)
* Update docs and output of matcher * Update docs and output of matcher
1 parent 2e27ed3 commit 7e70e27

9 files changed

+83
-15
lines changed

docs/manual.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# goss manual
22

3-
**Note:** For macOS and Windows, see: [platform-feature-parity](https://github.com/goss-org/goss/blob/master/docs/platform-feature-parity.md)
3+
**Notes:**
4+
5+
* For migration from v0.3.x to v0.4.x, see: [v4 migration](https://github.com/goss-org/goss/blob/master/docs/v4_migration.md)
6+
* For macOS and Windows, see: [platform-feature-parity](https://github.com/goss-org/goss/blob/master/docs/platform-feature-parity.md)
47

58
## Table of Contents
69

docs/v4_migration.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# v4 migration
2+
3+
4+
## Array matchers (e.g. user.groups) no longer allows duplicates
5+
6+
Goss v0.3.X allowed:
7+
8+
```yaml
9+
user:
10+
root:
11+
exists: true
12+
groups:
13+
- root
14+
- root
15+
- root
16+
```
17+
18+
Goss v0.4.x, will fail with the above as group "root" is only in the slice once. However, with goss v0.4.x the array may contain
19+
matchers. The test below is valid for v0.4.x but not valid for v0.3.x
20+
21+
```yaml
22+
user:
23+
root:
24+
exists: true
25+
groups:
26+
- have-prefix: r
27+
```
28+
29+
## rpm now contains the full EVR version
30+
31+
To enable the ability to compare RPM versions in the future, The version matching of rpm has changed
32+
33+
from:
34+
35+
```
36+
rpm -q --nosignature --nohdrchk --nodigest --qf '%{VERSION}\n' package_name
37+
```
38+
39+
to:
40+
41+
```
42+
rpm -q --nosignature --nohdrchk --nodigest --qf '%|EPOCH?{%{EPOCH}:}:{}|%{VERSION}-%{RELEASE}\n' package_name
43+
```
44+
45+
## file.contains -> file.contents
46+
47+
File contains attribute has been renamed to file.contents
48+
49+
from:
50+
51+
```yaml
52+
file:
53+
/tmp/foo:
54+
exists: true
55+
contains: []
56+
```
57+
58+
to:
59+
60+
```
61+
file:
62+
/tmp/foo:
63+
exists: true
64+
contents: []
65+
```

matchers/contain_elements_matcher.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ func (m *ContainElementsMatcher) FailureResult(actual interface{}) MatcherResult
2121
missingElements := getUnexported(m, "missingElements")
2222
return MatcherResult{
2323
Actual: actual,
24-
Message: "to contain elements",
24+
Message: "to contain elements matching",
2525
Expected: m.Elements,
2626
MissingElements: missingElements,
2727
}
@@ -30,7 +30,7 @@ func (m *ContainElementsMatcher) FailureResult(actual interface{}) MatcherResult
3030
func (m *ContainElementsMatcher) NegatedFailureResult(actual interface{}) MatcherResult {
3131
return MatcherResult{
3232
Actual: actual,
33-
Message: "not to contain elements",
33+
Message: "not to contain elements matching",
3434
Expected: m.Elements,
3535
}
3636

testdata/out_matching_basic_failing.1.documentation

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Matching: basic_array: matches:
22
Expected
33
["group1","group2","group3"]
4-
to contain elements
4+
to contain elements matching
55
["group1","group2","group2","group4"]
66
the missing elements were
77
["group2","group4"]
@@ -129,7 +129,7 @@ not to satisfy all of these matchers
129129
Matching: negated_basic_array: matches:
130130
Expected
131131
["group1","group2","group3"]
132-
not to contain elements
132+
not to contain elements matching
133133
["group1","group2","group3"]
134134
Matching: negated_basic_array_consists_of: matches:
135135
Expected
@@ -218,7 +218,7 @@ Failures/Skipped:
218218
Matching: basic_array: matches:
219219
Expected
220220
["group1","group2","group3"]
221-
to contain elements
221+
to contain elements matching
222222
["group1","group2","group2","group4"]
223223
the missing elements were
224224
["group2","group4"]
@@ -361,7 +361,7 @@ not to satisfy all of these matchers
361361
Matching: negated_basic_array: matches:
362362
Expected
363363
["group1","group2","group3"]
364-
not to contain elements
364+
not to contain elements matching
365365
["group1","group2","group3"]
366366

367367
Matching: negated_basic_array_consists_of: matches:

testdata/out_matching_basic_failing.1.rspecish

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Failures/Skipped:
55
Matching: basic_array: matches:
66
Expected
77
["group1","group2","group3"]
8-
to contain elements
8+
to contain elements matching
99
["group1","group2","group2","group4"]
1010
the missing elements were
1111
["group2","group4"]
@@ -148,7 +148,7 @@ not to satisfy all of these matchers
148148
Matching: negated_basic_array: matches:
149149
Expected
150150
["group1","group2","group3"]
151-
not to contain elements
151+
not to contain elements matching
152152
["group1","group2","group3"]
153153

154154
Matching: negated_basic_array_consists_of: matches:

testdata/out_matching_basic_failing.1.tap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
1..27
2-
not ok 1 - Matching: basic_array: matches: Expected ["group1","group2","group3"] to contain elements ["group1","group2","group2","group4"] the missing elements were ["group2","group4"]
2+
not ok 1 - Matching: basic_array: matches: Expected ["group1","group2","group3"] to contain elements matching ["group1","group2","group2","group4"] the missing elements were ["group2","group4"]
33
not ok 2 - Matching: basic_array_consists_of: matches: Expected ["foo","bar","moo"] to consist of ["fox",{"have-prefix":"t"},"box"] the missing elements were ["fox",{"have-prefix":"t"},"box"] the extra elements were ["foo","bar","moo"]
44
not ok 3 - Matching: basic_array_matchers: matches: Expected ["foo","bar","moo"] to satisfy at least one of these matchers [{"contain-elements":["fox","box"]},{"contain-elements":["fox","bax"]},["fox","bax","mox"],{"consist-of":["fox",{"have-prefix":"t"},"box"]},{"contain-element":{"have-prefix":"x"}},{"contain-element":{"have-suffix":"x"}}]
55
not ok 4 - Matching: basic_int: matches: Expected 42 to be numerically eq 43
@@ -14,7 +14,7 @@ not ok 12 - Matching: basic_string_multiline: matches: Expected "this is a test1
1414
not ok 13 - Matching: basic_string_oneline: matches: Expected "this is a test1\n" to equal "this is a test9\n"
1515
not ok 14 - Matching: basic_string_regexp: matches: Expected "this is a test" to match regular expression "^foo"
1616
not ok 15 - Matching: negated_and: matches: Expected 42 not to satisfy all of these matchers [{"eq":42},{"eq":42}]
17-
not ok 16 - Matching: negated_basic_array: matches: Expected ["group1","group2","group3"] not to contain elements ["group1","group2","group3"]
17+
not ok 16 - Matching: negated_basic_array: matches: Expected ["group1","group2","group3"] not to contain elements matching ["group1","group2","group3"]
1818
not ok 17 - Matching: negated_basic_array_consists_of: matches: Expected ["foo","bar","moo"] not to consist of ["foo",{"have-prefix":"m"},"bar"]
1919
not ok 18 - Matching: negated_basic_array_contain_element: matches: Expected ["foo","bar","moo"] not to contain element matching "foo"
2020
not ok 19 - Matching: negated_basic_array_matchers: matches: Expected ["foo","bar","moo"] to satisfy at least one of these matchers [{"not":{"contain-elements":["foo","bar"]}},{"not":{"contain-elements":["foo","bar"]}},{"not":["foo","bar","moo"]},{"not":{"consist-of":["foo",{"have-prefix":"m"},"bar"]}},{"not":{"contain-element":{"have-prefix":"b"}}}]

testdata/out_matching_transformers_failing.1.documentation

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ the raw value was
1010
Matching: test_array: matches:
1111
Expected
1212
["45","46","47"]
13-
to contain elements
13+
to contain elements matching
1414
[{"contain-element":{"match-regexp":"5."}},"55",{"and":[{"ge":56},{"le":30}]}]
1515
the missing elements were
1616
[{"contain-element":{"match-regexp":"5."}},"55",{"and":[{"ge":56},{"le":30}]}]
@@ -187,7 +187,7 @@ the raw value was
187187
Matching: test_array: matches:
188188
Expected
189189
["45","46","47"]
190-
to contain elements
190+
to contain elements matching
191191
[{"contain-element":{"match-regexp":"5."}},"55",{"and":[{"ge":56},{"le":30}]}]
192192
the missing elements were
193193
[{"contain-element":{"match-regexp":"5."}},"55",{"and":[{"ge":56},{"le":30}]}]

testdata/out_matching_transformers_failing.1.rspecish

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ the raw value was
1515
Matching: test_array: matches:
1616
Expected
1717
["45","46","47"]
18-
to contain elements
18+
to contain elements matching
1919
[{"contain-element":{"match-regexp":"5."}},"55",{"and":[{"ge":56},{"le":30}]}]
2020
the missing elements were
2121
[{"contain-element":{"match-regexp":"5."}},"55",{"and":[{"ge":56},{"le":30}]}]

testdata/out_matching_transformers_failing.1.tap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
1..18
22
not ok 1 - Matching: basic_reader_as_array: matches: Expected ["foo bar","moo cow",""] to contain element matching {"contain-substring":"fox"} the transform chain was [{"to-array":{}}] the raw value was "foo bar\nmoo cow\n"
3-
not ok 2 - Matching: test_array: matches: Expected ["45","46","47"] to contain elements [{"contain-element":{"match-regexp":"5."}},"55",{"and":[{"ge":56},{"le":30}]}] the missing elements were [{"contain-element":{"match-regexp":"5."}},"55",{"and":[{"ge":56},{"le":30}]}]
3+
not ok 2 - Matching: test_array: matches: Expected ["45","46","47"] to contain elements matching [{"contain-element":{"match-regexp":"5."}},"55",{"and":[{"ge":56},{"le":30}]}] the missing elements were [{"contain-element":{"match-regexp":"5."}},"55",{"and":[{"ge":56},{"le":30}]}]
44
not ok 3 - Matching: test_gjson_have_key_array: matches: Expected {"arr":[{"nested":"cow"},{"nested2":"moo"}]} to satisfy at least one of these matchers [{"have-key":"fail"}] the transform chain was [{"gjson":{"Path":"@this"}}] the raw value was "{\"arr\": [{\"nested\": \"cow\"}, {\"nested2\": \"moo\"}]}"
55
not ok 4 - Matching: test_gjson_invalid: matches: Error matchers.Gjson{Path:"@this"}: Invalid json the transform chain was [{"gjson":{"Path":"@this"}}] the raw value was "{\"arr\""
66
not ok 5 - Matching: test_gjson_not_found: matches: Error matchers.Gjson{Path:"foo"}: Path not found: foo the transform chain was [{"gjson":{"Path":"foo"}}] the raw value was "{\"arr\": [{\"nested\": \"cow\"}, {\"nested2\": \"moo\"}]}"

0 commit comments

Comments
 (0)