matchers

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 18, 2020 License: MIT Imports: 6 Imported by: 0

README

matchers

PkgGoDev test codecov Go Report Card

Matchers for gomock

Usage

See examples

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func CmpEq

func CmpEq(x interface{}) gomock.Matcher
Example
package main

import (
	"testing"

	"github.com/golang/mock/gomock"

	"github.com/higebu/matchers"
	"github.com/higebu/matchers/example"
)

func main() {
	t := &testing.T{} // provided by test
	ctrl := gomock.NewController(t)
	m := example.NewMockFoo(ctrl)
	m.EXPECT().Bar(matchers.CmpEq([]*example.A{{Name: "blah"}})).Return(nil)
	m.Bar([]example.A{{Name: "blah"}})
}
Output:

func ProtoMsgEq

func ProtoMsgEq(x proto.Message) gomock.Matcher
Example
package main

import (
	"testing"

	"github.com/golang/mock/gomock"

	"github.com/higebu/matchers"
	"github.com/higebu/matchers/example"
	"github.com/higebu/matchers/testpb"
)

func main() {
	t := &testing.T{} // provided by test
	ctrl := gomock.NewController(t)
	m := example.NewMockFoo(ctrl)
	m.EXPECT().Bar(matchers.ProtoMsgEq(&testpb.Message{Name: "blah"})).Return(nil)
	m.Baz(&testpb.Message{Name: "blah"})
}
Output:

func TimestampEq

func TimestampEq(x *timestamppb.Timestamp) gomock.Matcher
Example
package main

import (
	"testing"

	"github.com/golang/mock/gomock"
	"github.com/golang/protobuf/ptypes"

	"github.com/higebu/matchers"
	"github.com/higebu/matchers/example"
)

func main() {
	t := &testing.T{} // provided by test
	ctrl := gomock.NewController(t)
	m := example.NewMockFoo(ctrl)
	now := ptypes.TimestampNow()
	m.EXPECT().Qux(matchers.TimestampEq(now)).Return(nil)
	m.Qux(now)
}
Output:

Types

This section is empty.

Directories

Path Synopsis
Package example is a generated GoMock package.
Package example is a generated GoMock package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL