Documentation ¶
Index ¶
- type FakeUser
- func (f *FakeUser) AssertIDCalled(t UserTestingT)
- func (f *FakeUser) AssertIDCalledN(t UserTestingT, n int)
- func (f *FakeUser) AssertIDCalledOnce(t UserTestingT)
- func (f *FakeUser) AssertIDNotCalled(t UserTestingT)
- func (f *FakeUser) AssertStringCalled(t UserTestingT)
- func (f *FakeUser) AssertStringCalledN(t UserTestingT, n int)
- func (f *FakeUser) AssertStringCalledOnce(t UserTestingT)
- func (f *FakeUser) AssertStringNotCalled(t UserTestingT)
- func (_f3 *FakeUser) ID() (ident1 string)
- func (f *FakeUser) IDCalled() bool
- func (f *FakeUser) IDCalledN(n int) bool
- func (f *FakeUser) IDCalledOnce() bool
- func (f *FakeUser) IDNotCalled() bool
- func (f *FakeUser) Reset()
- func (_f4 *FakeUser) SetIDStub(ident1 string)
- func (_f2 *FakeUser) SetStringStub(ident5 string)
- 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 User
- type UserIDInvocation
- type UserStringInvocation
- type UserTestingT
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 []*UserStringInvocation IDCalls []*UserIDInvocation }
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 UserTestingT) *FakeUser
NewFakeUserDefaultError returns an instance of FakeUser with all hooks configured to call t.Error
func NewFakeUserDefaultFatal ¶
func NewFakeUserDefaultFatal(t UserTestingT) *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 UserTestingT)
AssertIDCalled calls t.Error if FakeUser.ID was not called
func (*FakeUser) AssertIDCalledN ¶
func (f *FakeUser) AssertIDCalledN(t UserTestingT, n int)
AssertIDCalledN calls t.Error if FakeUser.ID was called less than n times
func (*FakeUser) AssertIDCalledOnce ¶
func (f *FakeUser) AssertIDCalledOnce(t UserTestingT)
AssertIDCalledOnce calls t.Error if FakeUser.ID was not called exactly once
func (*FakeUser) AssertIDNotCalled ¶
func (f *FakeUser) AssertIDNotCalled(t UserTestingT)
AssertIDNotCalled calls t.Error if FakeUser.ID was called
func (*FakeUser) AssertStringCalled ¶
func (f *FakeUser) AssertStringCalled(t UserTestingT)
AssertStringCalled calls t.Error if FakeUser.String was not called
func (*FakeUser) AssertStringCalledN ¶
func (f *FakeUser) AssertStringCalledN(t UserTestingT, n int)
AssertStringCalledN calls t.Error if FakeUser.String was called less than n times
func (*FakeUser) AssertStringCalledOnce ¶
func (f *FakeUser) AssertStringCalledOnce(t UserTestingT)
AssertStringCalledOnce calls t.Error if FakeUser.String was not called exactly once
func (*FakeUser) AssertStringNotCalled ¶
func (f *FakeUser) AssertStringNotCalled(t UserTestingT)
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) SetIDStub ¶ added in v0.3.1
SetIDStub configures User.ID to always return the given values
func (*FakeUser) SetStringStub ¶ added in v0.3.1
SetStringStub configures User.String to always return the given values
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 UserIDInvocation ¶ added in v0.3.0
type UserIDInvocation struct { Results struct { Ident1 string } }
UserIDInvocation represents a single call of FakeUser.ID
type UserStringInvocation ¶ added in v0.3.0
type UserStringInvocation struct { Results struct { Ident5 string } }
UserStringInvocation represents a single call of FakeUser.String
type UserTestingT ¶ added in v0.3.0
type UserTestingT interface { Error(...interface{}) Errorf(string, ...interface{}) Fatal(...interface{}) Helper() }
UserTestingT represents the methods of "testing".T used by charlatan Fakes. It avoids importing the testing package.