gomml

package module
v0.0.0-...-41f5659 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2023 License: MIT Imports: 8 Imported by: 0

README

gomml: gomock matcher library

Build Status Go Report Card codecov GoDoc

gomml is a library of GoMock's matchers.

  • To expect bcrypted hash (golang.org/x/crypto/bcrypt)
  • To expect complex struct (github.com/google/go-cmp/cmp)
  • To check consistency of parameters
  • time.Now()
  • regexp

See examples

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BCrypt

func BCrypt(password []byte) gomock.Matcher

BCrypt is a Matcher that matches if the hashed parameter to the mock function is equivalent to the password.

Example usage:

dbMock.EXPECT().
	Insert(gomml.BCrypt("password").
	Return(errors.New("DB error"))

func Cmp

func Cmp(t *testing.T, want interface{}, opts ...cmp.Option) gomock.Matcher

Cmp is a Matcher that matches using go-cmp.

Example usage:

dbMock.EXPECT().
	Insert(gomml.Cmp(&someComplex).

func Consistent

func Consistent(m gomock.Matcher) gomock.Matcher

Consistent is a Matcher that matches with consistent.

The value must be the time between the constructor was called and it is validated.

Example usage:

consistentNow := gomml.Consistent(gomml.Now())
dbMock.EXPECT().
	Insert(consistentNow, consistentNow).

func Now

func Now() gomock.Matcher

Now is a Matcher that matches with now.

The value must be the time between the constructor was called and it is validated.

Example usage:

dbMock.EXPECT().
	Insert(gomml.Now()).

func Regexp

func Regexp(pattern string) gomock.Matcher

Regexp is a Matcher that matches with regexp.

Example usage:

dbMock.EXPECT().
	Insert(gomml.Regexp("^prefix-\\d+$").

Types

This section is empty.

Directories

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

Jump to

Keyboard shortcuts

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