Documentation
¶
Index ¶
- type FakeUser
- func (f *FakeUser) AssertIDCalled(t *testing.T)
- func (f *FakeUser) AssertIDCalledN(t *testing.T, n int)
- func (f *FakeUser) AssertIDCalledOnce(t *testing.T)
- func (f *FakeUser) AssertIDNotCalled(t *testing.T)
- func (f *FakeUser) AssertStringCalled(t *testing.T)
- func (f *FakeUser) AssertStringCalledN(t *testing.T, n int)
- func (f *FakeUser) AssertStringCalledOnce(t *testing.T)
- func (f *FakeUser) AssertStringNotCalled(t *testing.T)
- func (_f2 *FakeUser) ID() (ident6 string)
- func (f *FakeUser) IDCalled() bool
- func (f *FakeUser) IDCalledN(n int) bool
- func (f *FakeUser) IDCalledOnce() bool
- func (f *FakeUser) IDNotCalled() bool
- func (_f1 *FakeUser) String() (ident5 string)
- func (f *FakeUser) StringCalled() bool
- func (f *FakeUser) StringCalledN(n int) bool
- func (f *FakeUser) StringCalledOnce() bool
- func (f *FakeUser) StringNotCalled() bool
- type IDInvocation
- type StringInvocation
- type User
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 ¶
NewFakeUserDefaultError returns an instance of FakeUser with all hooks configured to call t.Error
func NewFakeUserDefaultFatal ¶
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 ¶
AssertIDCalled calls t.Error if FakeUser.ID was not called
func (*FakeUser) AssertIDCalledN ¶
AssertIDCalledN calls t.Error if FakeUser.ID was called less than n times
func (*FakeUser) AssertIDCalledOnce ¶
AssertIDCalledOnce calls t.Error if FakeUser.ID was not called exactly once
func (*FakeUser) AssertIDNotCalled ¶
AssertIDNotCalled calls t.Error if FakeUser.ID was called
func (*FakeUser) AssertStringCalled ¶
AssertStringCalled calls t.Error if FakeUser.String was not called
func (*FakeUser) AssertStringCalledN ¶
AssertStringCalledN calls t.Error if FakeUser.String was called less than n times
func (*FakeUser) AssertStringCalledOnce ¶
AssertStringCalledOnce calls t.Error if FakeUser.String was not called exactly once
func (*FakeUser) AssertStringNotCalled ¶
AssertStringNotCalled calls t.Error if FakeUser.String was called
func (*FakeUser) IDCalledOnce ¶
IDCalledOnce returns true if FakeUser.ID was called exactly once
func (*FakeUser) IDNotCalled ¶
IDNotCalled returns true if FakeUser.ID was not called
func (*FakeUser) StringCalled ¶
StringCalled returns true if FakeUser.String was called
func (*FakeUser) StringCalledN ¶
StringCalledN returns true if FakeUser.String was called at least n times
func (*FakeUser) StringCalledOnce ¶
StringCalledOnce returns true if FakeUser.String was called exactly once
func (*FakeUser) StringNotCalled ¶
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