Skip to content

Commit

Permalink
Adds Gomega have key (#224)
Browse files Browse the repository at this point in the history
  • Loading branch information
OmarDarwish authored and aelsabbahy committed Apr 23, 2017
1 parent 12d355a commit 2d36232
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
6 changes: 6 additions & 0 deletions resource/gomega.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ func matcherToGomegaMatcher(matcher interface{}) (types.GomegaMatcher, error) {
case "have-len":
value = sanitizeExpectedValue(value)
return gomega.HaveLen(value.(int)), nil
case "have-key":
subMatcher, err := matcherToGomegaMatcher(value)
if err != nil {
return nil, err
}
return gomega.HaveKey(subMatcher), nil
case "contain-element":
subMatcher, err := matcherToGomegaMatcher(value)
if err != nil {
Expand Down
4 changes: 4 additions & 0 deletions resource/gomega_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ var gomegaTests = []struct {
in: `{"have-len": 3}`,
want: gomega.HaveLen(3),
},
{
in: `{"have-key": "foo"}`,
want: gomega.HaveKey(gomega.Equal("foo")),
},

// Negation
{
Expand Down

0 comments on commit 2d36232

Please sign in to comment.