Skip to content

Commit

Permalink
new BeKeyOf matcher with documentation and unit tests (#590)
Browse files Browse the repository at this point in the history
  • Loading branch information
thediveo committed Sep 19, 2022
1 parent 647a36b commit fb586b3
Show file tree
Hide file tree
Showing 4 changed files with 386 additions and 241 deletions.
8 changes: 8 additions & 0 deletions docs/index.md
Expand Up @@ -966,6 +966,14 @@ The difference between the `ContainElements` and `ConsistOf` matchers is that th

succeeds if `ACTUAL` equals one of the elements passed into the matcher. When a single element `ELEMENT` of type `array` or `slice` is passed into the matcher, `BeElementOf` succeeds if `ELEMENT` contains an element that equals `ACTUAL` (reverse of `ContainElement`). `BeElementOf` always uses the `Equal()` matcher under the hood to assert equality.

#### BeKeyOf(m interface{})

```go
Ω(ACTUAL).Should(BeKeyOf(ELEMENT))
```

succeeds if `ACTUAL` equals one of the keys of the map passed into the matcher. `BeKeyOf` always uses the `Equal()` matcher under the hood to assert equality with a map key.

#### ConsistOf(element ...interface{})

```go
Expand Down

0 comments on commit fb586b3

Please sign in to comment.