mocks

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IfaceMock

type IfaceMock struct {
	// AppFunc mocks the App method.
	AppFunc func() chi.Router

	// ConfigFunc mocks the Config method.
	ConfigFunc func() *viper.Viper

	// DBFunc mocks the DB method.
	DBFunc func() *sqlx.DB

	// LoggerFunc mocks the Logger method.
	LoggerFunc func() log.Factory

	// ReposFunc mocks the Repos method.
	ReposFunc func() repos.Iface
	// contains filtered or unexported fields
}

IfaceMock is a mock implementation of injected.Iface.

func TestSomethingThatUsesIface(t *testing.T) {

	// make and configure a mocked injected.Iface
	mockedIface := &IfaceMock{
		AppFunc: func() chi.Router {
			panic("mock out the App method")
		},
		ConfigFunc: func() *viper.Viper {
			panic("mock out the Config method")
		},
		DBFunc: func() *sqlx.DB {
			panic("mock out the DB method")
		},
		LoggerFunc: func() log.Factory {
			panic("mock out the Logger method")
		},
		ReposFunc: func() repos.Iface {
			panic("mock out the Repos method")
		},
	}

	// use mockedIface in code that requires injected.Iface
	// and then make assertions.

}

func (*IfaceMock) App

func (mock *IfaceMock) App() chi.Router

App calls AppFunc.

func (*IfaceMock) AppCalls

func (mock *IfaceMock) AppCalls() []struct {
}

AppCalls gets all the calls that were made to App. Check the length with:

len(mockedIface.AppCalls())

func (*IfaceMock) Config

func (mock *IfaceMock) Config() *viper.Viper

Config calls ConfigFunc.

func (*IfaceMock) ConfigCalls

func (mock *IfaceMock) ConfigCalls() []struct {
}

ConfigCalls gets all the calls that were made to Config. Check the length with:

len(mockedIface.ConfigCalls())

func (*IfaceMock) DB

func (mock *IfaceMock) DB() *sqlx.DB

DB calls DBFunc.

func (*IfaceMock) DBCalls

func (mock *IfaceMock) DBCalls() []struct {
}

DBCalls gets all the calls that were made to DB. Check the length with:

len(mockedIface.DBCalls())

func (*IfaceMock) Logger

func (mock *IfaceMock) Logger() log.Factory

Logger calls LoggerFunc.

func (*IfaceMock) LoggerCalls

func (mock *IfaceMock) LoggerCalls() []struct {
}

LoggerCalls gets all the calls that were made to Logger. Check the length with:

len(mockedIface.LoggerCalls())

func (*IfaceMock) Repos

func (mock *IfaceMock) Repos() repos.Iface

Repos calls ReposFunc.

func (*IfaceMock) ReposCalls

func (mock *IfaceMock) ReposCalls() []struct {
}

ReposCalls gets all the calls that were made to Repos. Check the length with:

len(mockedIface.ReposCalls())

Jump to

Keyboard shortcuts

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