Skip to content

Commit

Permalink
Update docs and output (#833)
Browse files Browse the repository at this point in the history
* Update docs and output of matcher

* Update docs and output of matcher
  • Loading branch information
aelsabbahy authored Aug 23, 2023
1 parent 2e27ed3 commit 7e70e27
Show file tree
Hide file tree
Showing 9 changed files with 83 additions and 15 deletions.
5 changes: 4 additions & 1 deletion docs/manual.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# goss manual

**Note:** For macOS and Windows, see: [platform-feature-parity](https://github.com/goss-org/goss/blob/master/docs/platform-feature-parity.md)
**Notes:**

* 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)
* For macOS and Windows, see: [platform-feature-parity](https://github.com/goss-org/goss/blob/master/docs/platform-feature-parity.md)

## Table of Contents

Expand Down
65 changes: 65 additions & 0 deletions docs/v4_migration.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# v4 migration


## Array matchers (e.g. user.groups) no longer allows duplicates

Goss v0.3.X allowed:

```yaml
user:
root:
exists: true
groups:
- root
- root
- root
```
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
matchers. The test below is valid for v0.4.x but not valid for v0.3.x
```yaml
user:
root:
exists: true
groups:
- have-prefix: r
```
## rpm now contains the full EVR version
To enable the ability to compare RPM versions in the future, The version matching of rpm has changed
from:
```
rpm -q --nosignature --nohdrchk --nodigest --qf '%{VERSION}\n' package_name
```

to:

```
rpm -q --nosignature --nohdrchk --nodigest --qf '%|EPOCH?{%{EPOCH}:}:{}|%{VERSION}-%{RELEASE}\n' package_name
```

## file.contains -> file.contents

File contains attribute has been renamed to file.contents

from:

```yaml
file:
/tmp/foo:
exists: true
contains: []
```
to:
```
file:
/tmp/foo:
exists: true
contents: []
```
4 changes: 2 additions & 2 deletions matchers/contain_elements_matcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func (m *ContainElementsMatcher) FailureResult(actual interface{}) MatcherResult
missingElements := getUnexported(m, "missingElements")
return MatcherResult{
Actual: actual,
Message: "to contain elements",
Message: "to contain elements matching",
Expected: m.Elements,
MissingElements: missingElements,
}
Expand All @@ -30,7 +30,7 @@ func (m *ContainElementsMatcher) FailureResult(actual interface{}) MatcherResult
func (m *ContainElementsMatcher) NegatedFailureResult(actual interface{}) MatcherResult {
return MatcherResult{
Actual: actual,
Message: "not to contain elements",
Message: "not to contain elements matching",
Expected: m.Elements,
}

Expand Down
8 changes: 4 additions & 4 deletions testdata/out_matching_basic_failing.1.documentation
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Matching: basic_array: matches:
Expected
["group1","group2","group3"]
to contain elements
to contain elements matching
["group1","group2","group2","group4"]
the missing elements were
["group2","group4"]
Expand Down Expand Up @@ -129,7 +129,7 @@ not to satisfy all of these matchers
Matching: negated_basic_array: matches:
Expected
["group1","group2","group3"]
not to contain elements
not to contain elements matching
["group1","group2","group3"]
Matching: negated_basic_array_consists_of: matches:
Expected
Expand Down Expand Up @@ -218,7 +218,7 @@ Failures/Skipped:
Matching: basic_array: matches:
Expected
["group1","group2","group3"]
to contain elements
to contain elements matching
["group1","group2","group2","group4"]
the missing elements were
["group2","group4"]
Expand Down Expand Up @@ -361,7 +361,7 @@ not to satisfy all of these matchers
Matching: negated_basic_array: matches:
Expected
["group1","group2","group3"]
not to contain elements
not to contain elements matching
["group1","group2","group3"]

Matching: negated_basic_array_consists_of: matches:
Expand Down
4 changes: 2 additions & 2 deletions testdata/out_matching_basic_failing.1.rspecish
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Failures/Skipped:
Matching: basic_array: matches:
Expected
["group1","group2","group3"]
to contain elements
to contain elements matching
["group1","group2","group2","group4"]
the missing elements were
["group2","group4"]
Expand Down Expand Up @@ -148,7 +148,7 @@ not to satisfy all of these matchers
Matching: negated_basic_array: matches:
Expected
["group1","group2","group3"]
not to contain elements
not to contain elements matching
["group1","group2","group3"]

Matching: negated_basic_array_consists_of: matches:
Expand Down
4 changes: 2 additions & 2 deletions testdata/out_matching_basic_failing.1.tap
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
1..27
not ok 1 - Matching: basic_array: matches: Expected ["group1","group2","group3"] to contain elements ["group1","group2","group2","group4"] the missing elements were ["group2","group4"]
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"]
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"]
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"}}]
not ok 4 - Matching: basic_int: matches: Expected 42 to be numerically eq 43
Expand All @@ -14,7 +14,7 @@ not ok 12 - Matching: basic_string_multiline: matches: Expected "this is a test1
not ok 13 - Matching: basic_string_oneline: matches: Expected "this is a test1\n" to equal "this is a test9\n"
not ok 14 - Matching: basic_string_regexp: matches: Expected "this is a test" to match regular expression "^foo"
not ok 15 - Matching: negated_and: matches: Expected 42 not to satisfy all of these matchers [{"eq":42},{"eq":42}]
not ok 16 - Matching: negated_basic_array: matches: Expected ["group1","group2","group3"] not to contain elements ["group1","group2","group3"]
not ok 16 - Matching: negated_basic_array: matches: Expected ["group1","group2","group3"] not to contain elements matching ["group1","group2","group3"]
not ok 17 - Matching: negated_basic_array_consists_of: matches: Expected ["foo","bar","moo"] not to consist of ["foo",{"have-prefix":"m"},"bar"]
not ok 18 - Matching: negated_basic_array_contain_element: matches: Expected ["foo","bar","moo"] not to contain element matching "foo"
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"}}}]
Expand Down
4 changes: 2 additions & 2 deletions testdata/out_matching_transformers_failing.1.documentation
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ the raw value was
Matching: test_array: matches:
Expected
["45","46","47"]
to contain elements
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}]}]
Expand Down Expand Up @@ -187,7 +187,7 @@ the raw value was
Matching: test_array: matches:
Expected
["45","46","47"]
to contain elements
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}]}]
Expand Down
2 changes: 1 addition & 1 deletion testdata/out_matching_transformers_failing.1.rspecish
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ the raw value was
Matching: test_array: matches:
Expected
["45","46","47"]
to contain elements
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}]}]
Expand Down
2 changes: 1 addition & 1 deletion testdata/out_matching_transformers_failing.1.tap
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
1..18
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"
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}]}]
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}]}]
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\"}]}"
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\""
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\"}]}"
Expand Down

0 comments on commit 7e70e27

Please sign in to comment.