From e844b458651e5aa52c9f9cde69ec05c12396a8da Mon Sep 17 00:00:00 2001 From: Jim Myhrberg Date: Tue, 15 Feb 2022 01:46:11 +0000 Subject: [PATCH] docs(readme): add WithLabel and Any usage examples --- README.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/README.md b/README.md index b7aaf83..b93c88b 100644 --- a/README.md +++ b/README.md @@ -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