gomatcher

package module
v0.0.0-...-03fd60e Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2024 License: MIT Imports: 3 Imported by: 0

README

gomatcher

Matcher Collection for gomock

Installation

Use go get.

go get github.com/bickyeric/gomatcher

Then import the validator package into your own code.

import "github.com/bickyeric/gomatcher"

Working with Struct

Struct Including

Validating half of the data is more effective than using gomock.Any() matcher.

uc := mock.NewMockUserUsecase(ctrl)

// expect passed user to have field "Name" with value "John Doe"
uc.EXPECT().CreateUser(context.Background(), gomatcher.StructIncludes{
  "Name": "John Doe",
})

// this statement will pass
uc.CreateUser(context.Background(), usecase.User{
  ID:        123,
  Name:      "John Doe",
  CreatedAt: time.Now()
})

How to Contribute

Just make a pull request...

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type StructIncludes

type StructIncludes map[string]any

func (StructIncludes) Got

func (m StructIncludes) Got(got any) string

func (StructIncludes) Matches

func (ex StructIncludes) Matches(actual any) bool

func (StructIncludes) String

func (m StructIncludes) String() string

Directories

Path Synopsis
internal
usecase/mock
Package mock is a generated GoMock package.
Package mock is a generated GoMock package.

Jump to

Keyboard shortcuts

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