mirror of
https://github.com/romdo/gomockctx.git
synced 2026-02-19 08:06:40 +00:00
docs(readme): add WithLabel and Any usage examples
This commit is contained in:
18
README.md
18
README.md
@@ -26,6 +26,8 @@ import "github.com/romdo/gomockctx"
|
|||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
|
Match against a specific context or any of its child contexts:
|
||||||
|
|
||||||
```go
|
```go
|
||||||
// Create a context with a gomockctx ID value.
|
// Create a context with a gomockctx ID value.
|
||||||
ctx := gomockctx.New(context.Background())
|
ctx := gomockctx.New(context.Background())
|
||||||
@@ -39,6 +41,22 @@ someMock.EXPECT().
|
|||||||
someMock.Get(ctx, "foo")
|
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
|
## Documentation
|
||||||
|
|
||||||
Please see the
|
Please see the
|
||||||
|
|||||||
Reference in New Issue
Block a user