refactor: Deprecate Is() in favor of Eq() which behaves the same

This commit is contained in:
2022-03-21 09:46:46 +00:00
parent 668d42c683
commit a5361b5e0f
2 changed files with 21 additions and 5 deletions

View File

@@ -49,16 +49,28 @@ func New(parent context.Context) context.Context {
return context.WithValue(parent, ctxKey, newCtxID())
}
// Is accepts a context with a gomockctx ID value (as returned from New), and
// returns a gomock.Matcher which returns true for the given context, of any
// Eq accepts a context with a gomockctx ID value (as returned from New), and
// returns a gomock.Matcher which returns true for the given context, and any
// child contexts of it.
//
// If ctx was not returned from New, the resulting matcher will ALWAYS return
// false.
func Is(ctx context.Context) gomock.Matcher {
func Eq(ctx context.Context) gomock.Matcher {
return WithValue(ctxKey, getValue(ctx))
}
// Is accepts a context with a gomockctx ID value (as returned from New), and
// returns a gomock.Matcher which returns true for the given context, and any
// child contexts of it.
//
// If ctx was not returned from New, the resulting matcher will ALWAYS return
// false.
//
// Deprecated: Renamed to Eq().
func Is(ctx context.Context) gomock.Matcher {
return Eq(ctx)
}
// ID returns the gomockctx ID value in the given context, or a empty string if
// the context does not have a gomockctx ID value.
func ID(ctx context.Context) string {