mocks

package
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SessionStoreMock

type SessionStoreMock struct {
	// CreateSessionFunc mocks the CreateSession method.
	CreateSessionFunc func(ctx context.Context, token string, username string, expiresAt time.Time) error

	// DeleteAllSessionsFunc mocks the DeleteAllSessions method.
	DeleteAllSessionsFunc func(ctx context.Context) error

	// DeleteExpiredSessionsFunc mocks the DeleteExpiredSessions method.
	DeleteExpiredSessionsFunc func(ctx context.Context) (int64, error)

	// DeleteSessionFunc mocks the DeleteSession method.
	DeleteSessionFunc func(ctx context.Context, token string) error

	// DeleteSessionsByUsernameFunc mocks the DeleteSessionsByUsername method.
	DeleteSessionsByUsernameFunc func(ctx context.Context, username string) error

	// GetSessionFunc mocks the GetSession method.
	GetSessionFunc func(ctx context.Context, token string) (string, time.Time, error)
	// contains filtered or unexported fields
}

SessionStoreMock is a mock implementation of auth.SessionStore.

func TestSomethingThatUsesSessionStore(t *testing.T) {

	// make and configure a mocked auth.SessionStore
	mockedSessionStore := &SessionStoreMock{
		CreateSessionFunc: func(ctx context.Context, token string, username string, expiresAt time.Time) error {
			panic("mock out the CreateSession method")
		},
		DeleteAllSessionsFunc: func(ctx context.Context) error {
			panic("mock out the DeleteAllSessions method")
		},
		DeleteExpiredSessionsFunc: func(ctx context.Context) (int64, error) {
			panic("mock out the DeleteExpiredSessions method")
		},
		DeleteSessionFunc: func(ctx context.Context, token string) error {
			panic("mock out the DeleteSession method")
		},
		DeleteSessionsByUsernameFunc: func(ctx context.Context, username string) error {
			panic("mock out the DeleteSessionsByUsername method")
		},
		GetSessionFunc: func(ctx context.Context, token string) (string, time.Time, error) {
			panic("mock out the GetSession method")
		},
	}

	// use mockedSessionStore in code that requires auth.SessionStore
	// and then make assertions.

}

func (*SessionStoreMock) CreateSession

func (mock *SessionStoreMock) CreateSession(ctx context.Context, token string, username string, expiresAt time.Time) error

CreateSession calls CreateSessionFunc.

func (*SessionStoreMock) CreateSessionCalls

func (mock *SessionStoreMock) CreateSessionCalls() []struct {
	Ctx       context.Context
	Token     string
	Username  string
	ExpiresAt time.Time
}

CreateSessionCalls gets all the calls that were made to CreateSession. Check the length with:

len(mockedSessionStore.CreateSessionCalls())

func (*SessionStoreMock) DeleteAllSessions

func (mock *SessionStoreMock) DeleteAllSessions(ctx context.Context) error

DeleteAllSessions calls DeleteAllSessionsFunc.

func (*SessionStoreMock) DeleteAllSessionsCalls

func (mock *SessionStoreMock) DeleteAllSessionsCalls() []struct {
	Ctx context.Context
}

DeleteAllSessionsCalls gets all the calls that were made to DeleteAllSessions. Check the length with:

len(mockedSessionStore.DeleteAllSessionsCalls())

func (*SessionStoreMock) DeleteExpiredSessions

func (mock *SessionStoreMock) DeleteExpiredSessions(ctx context.Context) (int64, error)

DeleteExpiredSessions calls DeleteExpiredSessionsFunc.

func (*SessionStoreMock) DeleteExpiredSessionsCalls

func (mock *SessionStoreMock) DeleteExpiredSessionsCalls() []struct {
	Ctx context.Context
}

DeleteExpiredSessionsCalls gets all the calls that were made to DeleteExpiredSessions. Check the length with:

len(mockedSessionStore.DeleteExpiredSessionsCalls())

func (*SessionStoreMock) DeleteSession

func (mock *SessionStoreMock) DeleteSession(ctx context.Context, token string) error

DeleteSession calls DeleteSessionFunc.

func (*SessionStoreMock) DeleteSessionCalls

func (mock *SessionStoreMock) DeleteSessionCalls() []struct {
	Ctx   context.Context
	Token string
}

DeleteSessionCalls gets all the calls that were made to DeleteSession. Check the length with:

len(mockedSessionStore.DeleteSessionCalls())

func (*SessionStoreMock) DeleteSessionsByUsername

func (mock *SessionStoreMock) DeleteSessionsByUsername(ctx context.Context, username string) error

DeleteSessionsByUsername calls DeleteSessionsByUsernameFunc.

func (*SessionStoreMock) DeleteSessionsByUsernameCalls

func (mock *SessionStoreMock) DeleteSessionsByUsernameCalls() []struct {
	Ctx      context.Context
	Username string
}

DeleteSessionsByUsernameCalls gets all the calls that were made to DeleteSessionsByUsername. Check the length with:

len(mockedSessionStore.DeleteSessionsByUsernameCalls())

func (*SessionStoreMock) GetSession

func (mock *SessionStoreMock) GetSession(ctx context.Context, token string) (string, time.Time, error)

GetSession calls GetSessionFunc.

func (*SessionStoreMock) GetSessionCalls

func (mock *SessionStoreMock) GetSessionCalls() []struct {
	Ctx   context.Context
	Token string
}

GetSessionCalls gets all the calls that were made to GetSession. Check the length with:

len(mockedSessionStore.GetSessionCalls())

Jump to

Keyboard shortcuts

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