Skip to content

Commit

Permalink
[bugfix] Add Matching resource to NewGossConfig() (#280)
Browse files Browse the repository at this point in the history
* Fixes #278

* Add integration tests for matching resource
  • Loading branch information
OmarDarwish authored and aelsabbahy committed Sep 12, 2017
1 parent 013c595 commit 5e1f546
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 3 deletions.
5 changes: 5 additions & 0 deletions goss_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ func NewGossConfig() *GossConfig {
Mounts: make(resource.MountMap),
Interfaces: make(resource.InterfaceMap),
HTTPs: make(resource.HTTPMap),
Matchings: make(resource.MatchingMap),
}
}

Expand Down Expand Up @@ -157,5 +158,9 @@ func mergeGoss(g1, g2 GossConfig) GossConfig {
g1.HTTPs[k] = v
}

for k, v := range g2.Matchings {
g1.Matchings[k] = v
}

return g1
}
19 changes: 19 additions & 0 deletions integration-tests/goss/goss-shared.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -157,3 +157,22 @@ http:
allow-insecure: false
timeout: 5000
body: []
matching:
has_substr:
content: some string
matches:
match-regexp: some str
has_2:
content:
- 2
matches:
contain-element: 2
has_foo_bar_and_baz:
content:
foo: bar
baz: bing
matches:
and:
- have-key-with-value:
foo: bar
- have-key: baz
4 changes: 2 additions & 2 deletions integration-tests/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ out=$(docker_exec "/goss/$os/goss-linux-$arch" --vars "/goss/vars.yaml" -g "/gos
echo "$out"

if [[ $os == "arch" ]]; then
egrep -q 'Count: 65, Failed: 0' <<<"$out"
egrep -q 'Count: 68, Failed: 0' <<<"$out"
else
egrep -q 'Count: 79, Failed: 0' <<<"$out"
egrep -q 'Count: 82, Failed: 0' <<<"$out"
fi

if [[ ! $os == "arch" ]]; then
Expand Down
2 changes: 1 addition & 1 deletion resource/matching.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func (a *Matching) SetID(id string) { a.Id = id }
func (r *Matching) GetTitle() string { return r.Title }
func (r *Matching) GetMeta() meta { return r.Meta }

func (a *Matching) Validate(sys system.System) []TestResult {
func (a *Matching) Validate(sys *system.System) []TestResult {
skip := false

// ValidateValue expects a function
Expand Down

0 comments on commit 5e1f546

Please sign in to comment.