mockassert

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2026 License: MIT Imports: 4 Imported by: 0

README

✅ Gomock Assert

⚠️ This library has been moved to survivorbat/go-teq. This repository has been archived.

gomockassert is a gomock matcher that uses testify/assert to perform matches. Providing testify output for use in gomock.

⬇️ Installation

go get github.com/survivorbat/go-mockassert

📋 Usage

package main

import (
 "testing"

 "github.com/stretchr/testify/require"
 "go.uber.org/mock/gomock"
)

func TestExample(t *testing.T) {
  t.Parallel()
  // Arrange
  ctrl := gomock.NewController(t)

  testMock := NewMockTestInterface(ctrl)

  expected := &TestType{Name: "foo"}

  // Expect
  testMock.EXPECT().CreateTestType(gomock.Any(), mockassert.Eq(t, expected))

  // Act
  err := testMock.CreateTestType(t.Context())

  // Assert
  require.NoError(t, err)
}

🔭 Plans

Not much yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AssertFunc deprecated added in v0.0.1

type AssertFunc func(assert.TestingT, any, any, ...any) bool

AssertFunc matches the signature of assert.equal and similar functions

Deprecated: This library was moved to github.com/survivorbat/go-teq, please consider changing your imports

type Config deprecated added in v0.0.1

type Config struct {
	// AssertFunc can swap assert.Equal with other similar assertions
	AssertFunc AssertFunc
}

Config allows customisation for the behaviour of Matcher

Deprecated: This library was moved to github.com/survivorbat/go-teq, please consider changing your imports

type Matcher deprecated

type Matcher struct {
	T          *testing.T
	AssertFunc AssertFunc
	Expected   any
}

Matcher implements gomock.Matcher and uses Expected to assert with actual.

Deprecated: This library was moved to github.com/survivorbat/go-teq, please consider changing your imports

func Eq deprecated added in v0.0.2

func Eq(t *testing.T, expected any, opts ...Option) *Matcher

Eq ensures gomock will use testify to verify equality of the actual and the expected call.

Deprecated: This library was moved to github.com/survivorbat/go-teq, please consider changing your imports

func New deprecated

func New(t *testing.T, expected any, opts ...Option) *Matcher

New can be thrown directly into a EXPECT() call with the value you're expecting

Deprecated: This library was moved to github.com/survivorbat/go-teq, please consider changing your imports

func (*Matcher) Matches deprecated

func (m *Matcher) Matches(actual any) bool

Matches checks whether the expected value matches the actual

Deprecated: This library was moved to github.com/survivorbat/go-teq, please consider changing your imports

func (*Matcher) String deprecated

func (m *Matcher) String() string

String returns the type name that the matcher was created for

Deprecated: This library was moved to github.com/survivorbat/go-teq, please consider changing your imports

type Option deprecated added in v0.0.1

type Option func(*Config)

Option are used as input to the New method to customise behaviour

Deprecated: This library was moved to github.com/survivorbat/go-teq, please consider changing your imports

func ExportedValues deprecated added in v0.0.1

func ExportedValues() Option

ExportedValues sets the assertion function as assert.EqualExportedValues

Deprecated: This library was moved to github.com/survivorbat/go-teq, please consider changing your imports

func Values deprecated added in v0.0.1

func Values() Option

Values sets the assertion function as assert.EqualValues

Deprecated: This library was moved to github.com/survivorbat/go-teq, please consider changing your imports

Jump to

Keyboard shortcuts

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