connection

package
v0.48.0-beta1 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2022 License: Apache-2.0 Imports: 3 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Connection

type Connection interface {
	// Method to refresh the OAuth tokens
	RefreshTokens(ctx context.Context) error
	// Method to perform a logout request to the authentication server
	Logout(ctx context.Context) error
	// Method to create the API clients
	API() api.API
}

Connection is an interface which defines methods for interacting with the control plane API and the authentication server

type ConnectionMock

type ConnectionMock struct {
	// APIFunc mocks the API method.
	APIFunc func() api.API

	// LogoutFunc mocks the Logout method.
	LogoutFunc func(ctx context.Context) error

	// RefreshTokensFunc mocks the RefreshTokens method.
	RefreshTokensFunc func(ctx context.Context) error
	// contains filtered or unexported fields
}

ConnectionMock is a mock implementation of Connection.

func TestSomethingThatUsesConnection(t *testing.T) {

	// make and configure a mocked Connection
	mockedConnection := &ConnectionMock{
		APIFunc: func() apis.API {
			panic("mock out the API method")
		},
		LogoutFunc: func(ctx context.Context) error {
			panic("mock out the Logout method")
		},
		RefreshTokensFunc: func(ctx context.Context) error {
			panic("mock out the RefreshTokens method")
		},
	}

	// use mockedConnection in code that requires Connection
	// and then make assertions.

}

func (*ConnectionMock) API

func (mock *ConnectionMock) API() api.API

API calls APIFunc.

func (*ConnectionMock) APICalls

func (mock *ConnectionMock) APICalls() []struct {
}

APICalls gets all the calls that were made to API. Check the length with:

len(mockedConnection.APICalls())

func (*ConnectionMock) Logout

func (mock *ConnectionMock) Logout(ctx context.Context) error

Logout calls LogoutFunc.

func (*ConnectionMock) LogoutCalls

func (mock *ConnectionMock) LogoutCalls() []struct {
	Ctx context.Context
}

LogoutCalls gets all the calls that were made to Logout. Check the length with:

len(mockedConnection.LogoutCalls())

func (*ConnectionMock) RefreshTokens

func (mock *ConnectionMock) RefreshTokens(ctx context.Context) error

RefreshTokens calls RefreshTokensFunc.

func (*ConnectionMock) RefreshTokensCalls

func (mock *ConnectionMock) RefreshTokensCalls() []struct {
	Ctx context.Context
}

RefreshTokensCalls gets all the calls that were made to RefreshTokens. Check the length with:

len(mockedConnection.RefreshTokensCalls())

Directories

Path Synopsis
api

Jump to

Keyboard shortcuts

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