authenticatorMock

package
v3.2.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2019 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthenticatorGetTokenInvocation

type AuthenticatorGetTokenInvocation struct {
	Parameters struct {
		Scope string
	}
	Results struct {
		Token string
		Err   error
	}
}

AuthenticatorGetTokenInvocation represents a single call of FakeAuthenticator.GetToken

func NewAuthenticatorGetTokenInvocation

func NewAuthenticatorGetTokenInvocation(scope string, token string, err error) *AuthenticatorGetTokenInvocation

NewAuthenticatorGetTokenInvocation creates a new instance of AuthenticatorGetTokenInvocation

type AuthenticatorTestingT

type AuthenticatorTestingT interface {
	Error(...interface{})
	Errorf(string, ...interface{})
	Fatal(...interface{})
	Helper()
}

AuthenticatorTestingT represents the methods of "testing".T used by charlatan Fakes. It avoids importing the testing package.

type FakeAuthenticator

type FakeAuthenticator struct {
	GetTokenHook func(string) (string, error)

	GetTokenCalls []*AuthenticatorGetTokenInvocation
}

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

package example

func TestWithAuthenticator(t *testing.T) {
	f := &authenticatorMock.FakeAuthenticator{
		GetTokenHook: func(scope string) (token string, err error) {
			// ensure parameters meet expections, signal errors using t, etc
			return
		},
	}

	// test code goes here ...

	// assert state of FakeGetToken ...
	f.AssertGetTokenCalledOnce(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 FakeGetToken.

func NewFakeAuthenticatorDefaultError

func NewFakeAuthenticatorDefaultError(t_sym2 AuthenticatorTestingT) *FakeAuthenticator

NewFakeAuthenticatorDefaultError returns an instance of FakeAuthenticator with all hooks configured to call t.Error

func NewFakeAuthenticatorDefaultFatal

func NewFakeAuthenticatorDefaultFatal(t_sym1 AuthenticatorTestingT) *FakeAuthenticator

NewFakeAuthenticatorDefaultFatal returns an instance of FakeAuthenticator with all hooks configured to call t.Fatal

func NewFakeAuthenticatorDefaultPanic

func NewFakeAuthenticatorDefaultPanic() *FakeAuthenticator

NewFakeAuthenticatorDefaultPanic returns an instance of FakeAuthenticator with all hooks configured to panic

func (*FakeAuthenticator) AssertGetTokenCalled

func (f *FakeAuthenticator) AssertGetTokenCalled(t AuthenticatorTestingT)

AssertGetTokenCalled calls t.Error if FakeAuthenticator.GetToken was not called

func (*FakeAuthenticator) AssertGetTokenCalledN

func (f *FakeAuthenticator) AssertGetTokenCalledN(t AuthenticatorTestingT, n int)

AssertGetTokenCalledN calls t.Error if FakeAuthenticator.GetToken was called less than n times

func (*FakeAuthenticator) AssertGetTokenCalledOnce

func (f *FakeAuthenticator) AssertGetTokenCalledOnce(t AuthenticatorTestingT)

AssertGetTokenCalledOnce calls t.Error if FakeAuthenticator.GetToken was not called exactly once

func (*FakeAuthenticator) AssertGetTokenCalledOnceWith

func (f_sym9 *FakeAuthenticator) AssertGetTokenCalledOnceWith(t AuthenticatorTestingT, scope string)

AssertGetTokenCalledOnceWith calls t.Error if FakeAuthenticator.GetToken was not called exactly once with the given values

func (*FakeAuthenticator) AssertGetTokenCalledWith

func (f_sym7 *FakeAuthenticator) AssertGetTokenCalledWith(t AuthenticatorTestingT, scope string)

AssertGetTokenCalledWith calls t.Error if FakeAuthenticator.GetToken was not called with the given values

func (*FakeAuthenticator) AssertGetTokenNotCalled

func (f *FakeAuthenticator) AssertGetTokenNotCalled(t AuthenticatorTestingT)

AssertGetTokenNotCalled calls t.Error if FakeAuthenticator.GetToken was called

func (*FakeAuthenticator) GetToken

func (f_sym3 *FakeAuthenticator) GetToken(scope string) (token string, err error)

func (*FakeAuthenticator) GetTokenCalled

func (f *FakeAuthenticator) GetTokenCalled() bool

GetTokenCalled returns true if FakeAuthenticator.GetToken was called

func (*FakeAuthenticator) GetTokenCalledN

func (f *FakeAuthenticator) GetTokenCalledN(n int) bool

GetTokenCalledN returns true if FakeAuthenticator.GetToken was called at least n times

func (*FakeAuthenticator) GetTokenCalledOnce

func (f *FakeAuthenticator) GetTokenCalledOnce() bool

GetTokenCalledOnce returns true if FakeAuthenticator.GetToken was called exactly once

func (*FakeAuthenticator) GetTokenCalledOnceWith

func (f_sym8 *FakeAuthenticator) GetTokenCalledOnceWith(scope string) bool

GetTokenCalledOnceWith returns true if FakeAuthenticator.GetToken was called exactly once with the given values

func (*FakeAuthenticator) GetTokenCalledWith

func (f_sym6 *FakeAuthenticator) GetTokenCalledWith(scope string) bool

GetTokenCalledWith returns true if FakeAuthenticator.GetToken was called with the given values

func (*FakeAuthenticator) GetTokenNotCalled

func (f *FakeAuthenticator) GetTokenNotCalled() bool

GetTokenNotCalled returns true if FakeAuthenticator.GetToken was not called

func (*FakeAuthenticator) GetTokenResultsForCall

func (f_sym10 *FakeAuthenticator) GetTokenResultsForCall(scope string) (token string, err error, found_sym10 bool)

GetTokenResultsForCall returns the result values for the first call to FakeAuthenticator.GetToken with the given values

func (*FakeAuthenticator) Reset

func (f *FakeAuthenticator) Reset()

func (*FakeAuthenticator) SetGetTokenInvocation

func (f_sym5 *FakeAuthenticator) SetGetTokenInvocation(calls_sym5 []*AuthenticatorGetTokenInvocation, fallback_sym5 func() (string, error))

SetGetTokenInvocation configures Authenticator.GetToken to return the given results when called with the given parameters If no match is found for an invocation the result(s) of the fallback function are returned

func (*FakeAuthenticator) SetGetTokenStub

func (f_sym4 *FakeAuthenticator) SetGetTokenStub(token string, err error)

SetGetTokenStub configures Authenticator.GetToken to always return the given values

Jump to

Keyboard shortcuts

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