models

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2017 License: BSD-3-Clause Imports: 2 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FakeUser

type FakeUser struct {
	StringHook func() string
	IDHook     func() string

	StringCalls []*StringInvocation
	IDCalls     []*IDInvocation
}

FakeUser is a mock implementation of User for testing. Use it in your tests as in this example:

package example

func TestWithUser(t *testing.T) {
	f := &models.FakeUser{
		StringHook: func() (ident5 string) {
			// ensure parameters meet expections, signal errors using t, etc
			return
		},
	}

	// test code goes here ...

	// assert state of FakeString ...
	f.AssertStringCalledOnce(t)
}

Create anonymous function implementations for only those interface methods that should be called in the code under test. This will force a panic if any unexpected calls are made to FakeString.

func NewFakeUserDefaultError

func NewFakeUserDefaultError(t *testing.T) *FakeUser

NewFakeUserDefaultError returns an instance of FakeUser with all hooks configured to call t.Error

func NewFakeUserDefaultFatal

func NewFakeUserDefaultFatal(t *testing.T) *FakeUser

NewFakeUserDefaultFatal returns an instance of FakeUser with all hooks configured to call t.Fatal

func NewFakeUserDefaultPanic

func NewFakeUserDefaultPanic() *FakeUser

NewFakeUserDefaultPanic returns an instance of FakeUser with all hooks configured to panic

func (*FakeUser) AssertIDCalled

func (f *FakeUser) AssertIDCalled(t *testing.T)

AssertIDCalled calls t.Error if FakeUser.ID was not called

func (*FakeUser) AssertIDCalledN

func (f *FakeUser) AssertIDCalledN(t *testing.T, n int)

AssertIDCalledN calls t.Error if FakeUser.ID was called less than n times

func (*FakeUser) AssertIDCalledOnce

func (f *FakeUser) AssertIDCalledOnce(t *testing.T)

AssertIDCalledOnce calls t.Error if FakeUser.ID was not called exactly once

func (*FakeUser) AssertIDNotCalled

func (f *FakeUser) AssertIDNotCalled(t *testing.T)

AssertIDNotCalled calls t.Error if FakeUser.ID was called

func (*FakeUser) AssertStringCalled

func (f *FakeUser) AssertStringCalled(t *testing.T)

AssertStringCalled calls t.Error if FakeUser.String was not called

func (*FakeUser) AssertStringCalledN

func (f *FakeUser) AssertStringCalledN(t *testing.T, n int)

AssertStringCalledN calls t.Error if FakeUser.String was called less than n times

func (*FakeUser) AssertStringCalledOnce

func (f *FakeUser) AssertStringCalledOnce(t *testing.T)

AssertStringCalledOnce calls t.Error if FakeUser.String was not called exactly once

func (*FakeUser) AssertStringNotCalled

func (f *FakeUser) AssertStringNotCalled(t *testing.T)

AssertStringNotCalled calls t.Error if FakeUser.String was called

func (*FakeUser) ID

func (_f2 *FakeUser) ID() (ident6 string)

func (*FakeUser) IDCalled

func (f *FakeUser) IDCalled() bool

IDCalled returns true if FakeUser.ID was called

func (*FakeUser) IDCalledN

func (f *FakeUser) IDCalledN(n int) bool

IDCalledN returns true if FakeUser.ID was called at least n times

func (*FakeUser) IDCalledOnce

func (f *FakeUser) IDCalledOnce() bool

IDCalledOnce returns true if FakeUser.ID was called exactly once

func (*FakeUser) IDNotCalled

func (f *FakeUser) IDNotCalled() bool

IDNotCalled returns true if FakeUser.ID was not called

func (*FakeUser) String

func (_f1 *FakeUser) String() (ident5 string)

func (*FakeUser) StringCalled

func (f *FakeUser) StringCalled() bool

StringCalled returns true if FakeUser.String was called

func (*FakeUser) StringCalledN

func (f *FakeUser) StringCalledN(n int) bool

StringCalledN returns true if FakeUser.String was called at least n times

func (*FakeUser) StringCalledOnce

func (f *FakeUser) StringCalledOnce() bool

StringCalledOnce returns true if FakeUser.String was called exactly once

func (*FakeUser) StringNotCalled

func (f *FakeUser) StringNotCalled() bool

StringNotCalled returns true if FakeUser.String was not called

type IDInvocation

type IDInvocation struct {
	Results struct {
		Ident6 string
	}
}

IDInvocation represents a single call of FakeUser.ID

type StringInvocation

type StringInvocation struct {
	Results struct {
		Ident5 string
	}
}

StringInvocation represents a single call of FakeUser.String

type User

type User interface {
	fmt.Stringer
	ID() string
}

Jump to

Keyboard shortcuts

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