docs(readme): add WithLabel and Any usage examples

This commit is contained in:
2022-02-15 01:46:11 +00:00
parent 3610ef9e4a
commit e844b45865

View File

@@ -26,6 +26,8 @@ import "github.com/romdo/gomockctx"
## Usage
Match against a specific context or any of its child contexts:
```go
// Create a context with a gomockctx ID value.
ctx := gomockctx.New(context.Background())
@@ -39,6 +41,22 @@ someMock.EXPECT().
someMock.Get(ctx, "foo")
```
Match against a context containing a specific value:
```go
someMock.EXPECT().
Get(gomockctx.WithValue(myCtxKey, "hello"), "foo").
Return("bar", nil)
```
Match against any context:
```go
someMock.EXPECT().
Get(gomockctx.Any(), "foo").
Return("bar", nil)
```
## Documentation
Please see the