mock

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthHandlerMock

type AuthHandlerMock struct {
	// RequireFunc mocks the Require method.
	RequireFunc func(required auth.Permissions, handler http.HandlerFunc) http.HandlerFunc
	// contains filtered or unexported fields
}

AuthHandlerMock is a mock implementation of api.AuthHandler.

    func TestSomethingThatUsesAuthHandler(t *testing.T) {

        // make and configure a mocked api.AuthHandler
        mockedAuthHandler := &AuthHandlerMock{
            RequireFunc: func(required auth.Permissions, handler http.HandlerFunc) http.HandlerFunc {
	               panic("mock out the Require method")
            },
        }

        // use mockedAuthHandler in code that requires api.AuthHandler
        // and then make assertions.

    }

func (*AuthHandlerMock) Require

func (mock *AuthHandlerMock) Require(required auth.Permissions, handler http.HandlerFunc) http.HandlerFunc

Require calls RequireFunc.

func (*AuthHandlerMock) RequireCalls

func (mock *AuthHandlerMock) RequireCalls() []struct {
	Required auth.Permissions
	Handler  http.HandlerFunc
}

RequireCalls gets all the calls that were made to Require. Check the length with:

len(mockedAuthHandler.RequireCalls())

type CacheMock

type CacheMock struct {
	// DeleteAllFunc mocks the DeleteAll method.
	DeleteAllFunc func() error

	// GetByEmailFunc mocks the GetByEmail method.
	GetByEmailFunc func(email string) (*session.Session, error)

	// GetByIDFunc mocks the GetByID method.
	GetByIDFunc func(ID string) (*session.Session, error)

	// SetSessionFunc mocks the SetSession method.
	SetSessionFunc func(s *session.Session) error
	// contains filtered or unexported fields
}

CacheMock is a mock implementation of api.Cache.

    func TestSomethingThatUsesCache(t *testing.T) {

        // make and configure a mocked api.Cache
        mockedCache := &CacheMock{
            DeleteAllFunc: func() error {
	               panic("mock out the DeleteAll method")
            },
            GetByEmailFunc: func(email string) (*session.Session, error) {
	               panic("mock out the GetByEmail method")
            },
            GetByIDFunc: func(ID string) (*session.Session, error) {
	               panic("mock out the GetByID method")
            },
            SetSessionFunc: func(s *session.Session) error {
	               panic("mock out the SetSession method")
            },
        }

        // use mockedCache in code that requires api.Cache
        // and then make assertions.

    }

func (*CacheMock) DeleteAll

func (mock *CacheMock) DeleteAll() error

DeleteAll calls DeleteAllFunc.

func (*CacheMock) DeleteAllCalls

func (mock *CacheMock) DeleteAllCalls() []struct {
}

DeleteAllCalls gets all the calls that were made to DeleteAll. Check the length with:

len(mockedCache.DeleteAllCalls())

func (*CacheMock) GetByEmail added in v1.0.0

func (mock *CacheMock) GetByEmail(email string) (*session.Session, error)

GetByEmail calls GetByEmailFunc.

func (*CacheMock) GetByEmailCalls added in v1.0.0

func (mock *CacheMock) GetByEmailCalls() []struct {
	Email string
}

GetByEmailCalls gets all the calls that were made to GetByEmail. Check the length with:

len(mockedCache.GetByEmailCalls())

func (*CacheMock) GetByID

func (mock *CacheMock) GetByID(ID string) (*session.Session, error)

GetByID calls GetByIDFunc.

func (*CacheMock) GetByIDCalls

func (mock *CacheMock) GetByIDCalls() []struct {
	ID string
}

GetByIDCalls gets all the calls that were made to GetByID. Check the length with:

len(mockedCache.GetByIDCalls())

func (*CacheMock) SetSession added in v1.0.0

func (mock *CacheMock) SetSession(s *session.Session) error

SetSession calls SetSessionFunc.

func (*CacheMock) SetSessionCalls added in v1.0.0

func (mock *CacheMock) SetSessionCalls() []struct {
	S *session.Session
}

SetSessionCalls gets all the calls that were made to SetSession. Check the length with:

len(mockedCache.SetSessionCalls())

type SessionUpdaterMock

type SessionUpdaterMock struct {
	// UpdateFunc mocks the Update method.
	UpdateFunc func(email string) (*session.Session, error)
	// contains filtered or unexported fields
}

SessionUpdaterMock is a mock implementation of api.SessionUpdater.

    func TestSomethingThatUsesSessionUpdater(t *testing.T) {

        // make and configure a mocked api.SessionUpdater
        mockedSessionUpdater := &SessionUpdaterMock{
            UpdateFunc: func(email string) (*session.Session, error) {
	               panic("mock out the Update method")
            },
        }

        // use mockedSessionUpdater in code that requires api.SessionUpdater
        // and then make assertions.

    }

func (*SessionUpdaterMock) Update

func (mock *SessionUpdaterMock) Update(email string) (*session.Session, error)

Update calls UpdateFunc.

func (*SessionUpdaterMock) UpdateCalls

func (mock *SessionUpdaterMock) UpdateCalls() []struct {
	Email string
}

UpdateCalls gets all the calls that were made to Update. Check the length with:

len(mockedSessionUpdater.UpdateCalls())

Jump to

Keyboard shortcuts

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