mock

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2021 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// StaticTime represents a time.Time that displays the clock as 01:23:45.678
	StaticTime = time.Date(1989, 6, 22, 1, 23, 45, 0, time.UTC)
)

Functions

func FileWriter

func FileWriter(t *testing.T) (*os.File, error)

FileWriter is a mock terminal UI writer which sends command output to a file named after the test being run

func NewConsole

func NewConsole() (*bytes.Buffer, *expect.Console, terminal.UI, error)

NewConsole returns a new *bytes.Buffer and a *expect.Console along with its corresponding mock terminal UI that write to the buffer

func NewConsoleWithOptions

func NewConsoleWithOptions(options UIOptions, writers ...io.Writer) (*expect.Console, terminal.UI, error)

NewConsoleWithOptions creates a new *expect.Console along with its corresponding mock terminal UI based on the provided options

func NewProfile

func NewProfile(t *testing.T) *user.Profile

NewProfile returns a new CLI profile with a random name

func NewProfileFromTmpDir

func NewProfileFromTmpDir(t *testing.T, name string) (*user.Profile, func())

NewProfileFromTmpDir returns a new CLI profile with a random name and a current working directory based on a temporary directory along with the associated cleanup function

func NewProfileFromWd

func NewProfileFromWd(t *testing.T) *user.Profile

NewProfileFromWd returns a new CLI profile with a random name and the current working directory

func NewProfileWithSession

func NewProfileWithSession(t *testing.T, session realm.Session) *user.Profile

NewProfileWithSession returns a new CLI profile with a session

func NewUI

func NewUI() (*bytes.Buffer, terminal.UI)

NewUI returns a new *bytes.Buffer and a mock terminal UI that writes to the buffer

func NewUIWithOptions

func NewUIWithOptions(options UIOptions, writer io.Writer) terminal.UI

NewUIWithOptions creates a new mock terminal UI based on the provided options

func NewVT10XConsole

func NewVT10XConsole() (*bytes.Buffer, *expect.Console, *vt10x.State, terminal.UI, error)

NewVT10XConsole returns a new *bytes.Buffer and a *expect.Console along with its corresponding *vt10.State and mock terminal UI that write to the buffer

func NewVT10XConsoleWithOptions

func NewVT10XConsoleWithOptions(options UIOptions, writers ...io.Writer) (*expect.Console, *vt10x.State, terminal.UI, error)

NewVT10XConsoleWithOptions creates a new *expect.Console along with its corresponding *vt10.State and mock terminal UI based on the provided options

Types

type AtlasClient

type AtlasClient struct {
	atlas.Client
	GroupsFn    func() ([]atlas.Group, error)
	ClustersFn  func(groupID string) ([]atlas.Cluster, error)
	DataLakesFn func(groupID string) ([]atlas.DataLake, error)
}

AtlasClient is a mocked Atlas client

func (AtlasClient) Clusters

func (ac AtlasClient) Clusters(groupID string) ([]atlas.Cluster, error)

Clusters calls the mocked Clusters implementation if provided, otherwise the call falls back to the underlying atlas.Client implementation. NOTE: this may panic if the underlying atlas.Client is left undefined

func (AtlasClient) DataLakes

func (ac AtlasClient) DataLakes(groupID string) ([]atlas.DataLake, error)

DataLakes calls the mocked DataLakes implementation if provided, otherwise the call falls back to the underlying atlas.Client implementation. NOTE: this may panic if the underlying atlas.Client is left undefined

func (AtlasClient) Groups

func (ac AtlasClient) Groups() ([]atlas.Group, error)

Groups calls the mocked Groups implementation if provided, otherwise the call falls back to the underlying atlas.Client implementation. NOTE: this may panic if the underlying atlas.Client is left undefined

type RealmClient

type RealmClient struct {
	realm.Client

	AuthenticateFn func(publicAPIKey, privateAPIKey string) (realm.Session, error)
	AuthProfileFn  func() (realm.AuthProfile, error)

	DiffFn   func(groupID, appID string, appData interface{}) ([]string, error)
	ExportFn func(groupID, appID string, req realm.ExportRequest) (string, *zip.Reader, error)
	ImportFn func(groupID, appID string, appData interface{}) error

	ExportDependenciesFn func(groupID, appID string) (string, io.ReadCloser, error)
	ImportDependenciesFn func(groupID, appID, uploadPath string) error
	DiffDependenciesFn   func(groupID, appID, uploadPath string) (realm.DependenciesDiff, error)

	CreateAppFn      func(groupID, name string, meta realm.AppMeta) (realm.App, error)
	DeleteAppFn      func(groupID, appID string) error
	FindAppsFn       func(filter realm.AppFilter) ([]realm.App, error)
	AppDescriptionFn func(groupID, appID string) (realm.AppDescription, error)

	CreateDraftFn  func(groupID, appID string) (realm.AppDraft, error)
	DiffDraftFn    func(groupID, appID, draftID string) (realm.AppDraftDiff, error)
	DiscardDraftFn func(groupID, appID, draftID string) error
	DraftFn        func(groupID, appID string) (realm.AppDraft, error)

	DeployDraftFn func(groupID, appID, draftID string) (realm.AppDeployment, error)
	DeploymentFn  func(groupID, appID, deploymentID string) (realm.AppDeployment, error)

	SecretsFn      func(groupID, appID string) ([]realm.Secret, error)
	CreateSecretFn func(groupID, appID, name, value string) (realm.Secret, error)
	DeleteSecretFn func(groupID, appID, secretID string) error
	UpdateSecretFn func(groupID, appID, secretID, name, value string) error

	CreateAPIKeyFn      func(groupID, appID, apiKeyName string) (realm.APIKey, error)
	CreateUserFn        func(groupID, appID, email, password string) (realm.User, error)
	DeleteUserFn        func(groupID, appID, userID string) error
	DisableUserFn       func(groupID, appID, userID string) error
	EnableUserFn        func(groupID, appID, userID string) error
	FindUsersFn         func(groupID, appID string, filter realm.UserFilter) ([]realm.User, error)
	RevokeUserSessionFn func(groupID, appID, userID string) error

	HostingAssetsFn                func(groupID, appID string) ([]realm.HostingAsset, error)
	HostingAssetUploadFn           func(groupID, appID, rootDir string, asset realm.HostingAsset) error
	HostingAssetRemoveFn           func(groupID, appID, path string) error
	HostingAssetAttributesUpdateFn func(groupID, appID, path string, attrs ...realm.HostingAssetAttribute) error
	HostingCacheInvalidateFn       func(groupID, appID, path string) error

	FunctionsFn               func(groupID, appID string) ([]realm.Function, error)
	AppDebugExecuteFunctionFn func(groupID, appID, userID, name string, args []interface{}) (realm.ExecutionResults, error)

	LogsFn func(groupID, appID string, opts realm.LogsOptions) (realm.Logs, error)

	SchemaModelsFn func(groupID, appID, language string) ([]realm.SchemaModel, error)

	TemplatesFn      func() ([]realm.Template, error)
	ClientTemplateFn func(groupID, appID, templateID string) (*zip.Reader, error)

	StatusFn func() error
}

RealmClient is a mocked Realm client

func (RealmClient) AppDebugExecuteFunction

func (rc RealmClient) AppDebugExecuteFunction(groupID, appID, userID, name string, args []interface{}) (realm.ExecutionResults, error)

AppDebugExecuteFunction calls the mocked AppDebugExecuteFunction implementation if provided, otherwise the call falls back to the underlying realm.Client implementation. NOTE: this may panic if the underlying realm.Client is left undefined

func (RealmClient) AppDescription

func (rc RealmClient) AppDescription(groupID, appID string) (realm.AppDescription, error)

AppDescription calls the mocked AppDescription implementation if provided, otherwise the call falls back to the underlying realm.Client implementation. NOTE: this may panic if the underlying realm.Client is left undefined

func (RealmClient) AuthProfile

func (rc RealmClient) AuthProfile() (realm.AuthProfile, error)

AuthProfile calls the mocked AuthProfile implementation if provided, otherwise the call falls back to the underlying realm.Client implementation. NOTE: this may panic if the underlying realm.Client is left undefined

func (RealmClient) Authenticate

func (rc RealmClient) Authenticate(publicAPIKey, privateAPIKey string) (realm.Session, error)

Authenticate calls the mocked Authenticate implementation if provided, otherwise the call falls back to the underlying realm.Client implementation. NOTE: this may panic if the underlying realm.Client is left undefined

func (RealmClient) ClientTemplate

func (rc RealmClient) ClientTemplate(groupID, appID, templateID string) (*zip.Reader, error)

ClientTemplate calls the mocked ClientTemplate implementation if provided, otherwise the call falls back to the underlying realm.Client implementation. NOTE: this may panic if the underlying realm.Client is left undefined

func (RealmClient) CreateAPIKey

func (rc RealmClient) CreateAPIKey(groupID, appID, apiKeyName string) (realm.APIKey, error)

CreateAPIKey calls the mocked CreateAPIKey implementation if provided, otherwise the call falls back to the underlying realm.Client implementation. NOTE: this may panic if the underlying realm.Client is left undefined

func (RealmClient) CreateApp

func (rc RealmClient) CreateApp(groupID, name string, meta realm.AppMeta) (realm.App, error)

CreateApp calls the mocked CreateApp implementation if provided, otherwise the call falls back to the underlying realm.Client implementation. NOTE: this may panic if the underlying realm.Client is left undefined

func (RealmClient) CreateDraft

func (rc RealmClient) CreateDraft(groupID, appID string) (realm.AppDraft, error)

CreateDraft calls the mocked CreateDraft implementation if provided, otherwise the call falls back to the underlying realm.Client implementation. NOTE: this may panic if the underlying realm.Client is left undefined

func (RealmClient) CreateSecret

func (rc RealmClient) CreateSecret(groupID, appID, name, value string) (realm.Secret, error)

CreateSecret calls the mocked CreateSecret implementation if provided, otherwise the call falls back to the underlying realm.Client implementation. NOTE: this may panic if the underlying realm.Client is left undefined

func (RealmClient) CreateUser

func (rc RealmClient) CreateUser(groupID, appID, email, password string) (realm.User, error)

CreateUser calls the mocked CreateUser implementation if provided, otherwise the call falls back to the underlying realm.Client implementation. NOTE: this may panic if the underlying realm.Client is left undefined

func (RealmClient) DeleteApp

func (rc RealmClient) DeleteApp(groupID, appID string) error

DeleteApp calls the mocked DeleteApp implementation if provided, otherwise the call falls back to the underlying realm.Client implementation. NOTE: this may panic if the underlying realm.Client is left undefined

func (RealmClient) DeleteSecret

func (rc RealmClient) DeleteSecret(groupID, appID, secretID string) error

DeleteSecret calls the mocked DeleteSecret implementation if provided, otherwise the call falls back to the underlying realm.Client implementation NOTE: this may panic if the underlying realm.Client is left undefined

func (RealmClient) DeleteUser

func (rc RealmClient) DeleteUser(groupID, appID, userID string) error

DeleteUser calls the mocked DeleteUser implementation if provided, otherwise the call falls back to the underlying realm.Client implementation. NOTE: this may panic if the underlying realm.Client is left undefined

func (RealmClient) DeployDraft

func (rc RealmClient) DeployDraft(groupID, appID, draftID string) (realm.AppDeployment, error)

DeployDraft calls the mocked DeployDraft implementation if provided, otherwise the call falls back to the underlying realm.Client implementation. NOTE: this may panic if the underlying realm.Client is left undefined

func (RealmClient) Deployment

func (rc RealmClient) Deployment(groupID, appID, deploymentID string) (realm.AppDeployment, error)

Deployment calls the mocked Deployment implementation if provided, otherwise the call falls back to the underlying realm.Client implementation. NOTE: this may panic if the underlying realm.Client is left undefined

func (RealmClient) Diff

func (rc RealmClient) Diff(groupID, appID string, appData interface{}) ([]string, error)

Diff calls the mocked Diff implementation if provided, otherwise the call falls back to the underlying realm.Client implementation. NOTE: this may panic if the underlying realm.Client is left undefined

func (RealmClient) DiffDependencies

func (rc RealmClient) DiffDependencies(groupID, appID, uploadPath string) (realm.DependenciesDiff, error)

DiffDependencies calls the mocked DiffDependencies implementation if provided, otherwise the call falls back to the underlying realm.Client implementation. NOTE: this may panic if the underlying realm.Client is left undefined

func (RealmClient) DiffDraft

func (rc RealmClient) DiffDraft(groupID, appID, draftID string) (realm.AppDraftDiff, error)

DiffDraft calls the mocked DiffDraft implementation if provided, otherwise the call falls back to the underlying realm.Client implementation. NOTE: this may panic if the underlying realm.Client is left undefined

func (RealmClient) DisableUser

func (rc RealmClient) DisableUser(groupID, appID, userID string) error

DisableUser calls the mocked DisableUser implementation if provided, otherwise the call falls back to the underlying realm.Client implementation. NOTE: this may panic if the underlying realm.Client is left undefined

func (RealmClient) DiscardDraft

func (rc RealmClient) DiscardDraft(groupID, appID, draftID string) error

DiscardDraft calls the mocked DiscardDraft implementation if provided, otherwise the call falls back to the underlying realm.Client implementation. NOTE: this may panic if the underlying realm.Client is left undefined

func (RealmClient) Draft

func (rc RealmClient) Draft(groupID, appID string) (realm.AppDraft, error)

Draft calls the mocked Draft implementation if provided, otherwise the call falls back to the underlying realm.Client implementation. NOTE: this may panic if the underlying realm.Client is left undefined

func (RealmClient) EnableUser

func (rc RealmClient) EnableUser(groupID, appID, userID string) error

EnableUser calls the mocked EnableUser implementation if provided, otherwise the call falls back to the underlying realm.Client implementation. NOTE: this may panic if the underlying realm.Client is left undefined

func (RealmClient) Export

func (rc RealmClient) Export(groupID, appID string, req realm.ExportRequest) (string, *zip.Reader, error)

Export calls the mocked Export implementation if provided, otherwise the call falls back to the underlying realm.Client implementation. NOTE: this may panic if the underlying realm.Client is left undefined

func (RealmClient) ExportDependencies

func (rc RealmClient) ExportDependencies(groupID, appID string) (string, io.ReadCloser, error)

ExportDependencies calls the mocked ExportDependencies implementation if provided, otherwise the call falls back to the underlying realm.Client implementation. NOTE: this may panic if the underlying realm.Client is left undefined

func (RealmClient) FindApps

func (rc RealmClient) FindApps(filter realm.AppFilter) ([]realm.App, error)

FindApps calls the mocked FindApps implementation if provided, otherwise the call falls back to the underlying realm.Client implementation. NOTE: this may panic if the underlying realm.Client is left undefined

func (RealmClient) FindUsers

func (rc RealmClient) FindUsers(groupID, appID string, filter realm.UserFilter) ([]realm.User, error)

FindUsers calls the mocked FindUsers implementation if provided, otherwise the call falls back to the underlying realm.Client implementation. NOTE: this may panic if the underlying realm.Client is left undefined

func (RealmClient) Functions

func (rc RealmClient) Functions(groupID, appID string) ([]realm.Function, error)

Functions calls the mocked Functions implementation if provided, otherwise the call falls back to the underlying realm.Client implementation. NOTE: this may panic if the underlying realm.Client is left undefined

func (RealmClient) HostingAssetAttributesUpdate

func (rc RealmClient) HostingAssetAttributesUpdate(groupID, appID, path string, attrs ...realm.HostingAssetAttribute) error

HostingAssetAttributesUpdate calls the mocked HostingAssetAttributesUpdate implementation if provided, otherwise the call falls back to the underlying realm.Client implementation. NOTE: this may panic if the underlying realm.Client is left undefined

func (RealmClient) HostingAssetRemove

func (rc RealmClient) HostingAssetRemove(groupID, appID, path string) error

HostingAssetRemove calls the mocked HostingAssetRemove implementation if provided, otherwise the call falls back to the underlying realm.Client implementation. NOTE: this may panic if the underlying realm.Client is left undefined

func (RealmClient) HostingAssetUpload

func (rc RealmClient) HostingAssetUpload(groupID, appID, rootDir string, asset realm.HostingAsset) error

HostingAssetUpload calls the mocked HostingAssetUpload implementation if provided, otherwise the call falls back to the underlying realm.Client implementation. NOTE: this may panic if the underlying realm.Client is left undefined

func (RealmClient) HostingAssets

func (rc RealmClient) HostingAssets(groupID, appID string) ([]realm.HostingAsset, error)

HostingAssets calls the mocked HostingAssets implementation if provided, otherwise the call falls back to the underlying realm.Client implementation. NOTE: this may panic if the underlying realm.Client is left undefined

func (RealmClient) HostingCacheInvalidate

func (rc RealmClient) HostingCacheInvalidate(groupID, appID, path string) error

HostingCacheInvalidate calls the mocked HostingCacheInvalidate implementation if provided, otherwise the call falls back to the underlying realm.Client implementation. NOTE: this may panic if the underlying realm.Client is left undefined

func (RealmClient) Import

func (rc RealmClient) Import(groupID, appID string, appData interface{}) error

Import calls the mocked Import implementation if provided, otherwise the call falls back to the underlying realm.Client implementation. NOTE: this may panic if the underlying realm.Client is left undefined

func (RealmClient) ImportDependencies

func (rc RealmClient) ImportDependencies(groupID, appID, uploadPath string) error

ImportDependencies calls the mocked ImportDependencies implementation if provided, otherwise the call falls back to the underlying realm.Client implementation. NOTE: this may panic if the underlying realm.Client is left undefined

func (RealmClient) Logs

func (rc RealmClient) Logs(groupID, appID string, opts realm.LogsOptions) (realm.Logs, error)

Logs calls the mocked Logs implementation if provided, otherwise the call falls back to the underlying realm.Client implementation. NOTE: this may panic if the underlying realm.Client is left undefined

func (RealmClient) RevokeUserSessions

func (rc RealmClient) RevokeUserSessions(groupID, appID, userID string) error

RevokeUserSessions calls the mocked RevokeUserSessions implementation if provided, otherwise the call falls back to the underlying realm.Client implementation. NOTE: this may panic if the underlying realm.Client is left undefined

func (RealmClient) SchemaModels

func (rc RealmClient) SchemaModels(groupID, appID, language string) ([]realm.SchemaModel, error)

SchemaModels calls the mocked SchemaModels implementation if provided, otherwise the call falls back to the underlying realm.Client implementation. NOTE: this may panic if the underlying realm.Client is left undefined

func (RealmClient) Secrets

func (rc RealmClient) Secrets(groupID, appID string) ([]realm.Secret, error)

Secrets calls the mocked Secrets implementation if provided, otherwise the call falls back to the underlying realm.Client implementation. NOTE: this may panic if the underlying realm.Client is left undefined

func (RealmClient) Status

func (rc RealmClient) Status() error

Status calls the mocked Status implementation if provided, otherwise the call falls back to the underlying realm.Client implementation. NOTE: this may panic if the underlying realm.Client is left undefined

func (RealmClient) Templates

func (rc RealmClient) Templates() ([]realm.Template, error)

Templates calls the mocked Templates implementation if provided, otherwise the call falls back to the underlying realm.Client implementation. NOTE: this may panic if the underlying realm.Client is left undefined

func (RealmClient) UpdateSecret

func (rc RealmClient) UpdateSecret(groupID, appID, secretID, name, value string) error

UpdateSecret calls the mocked UpdateSecret implementation if provided, otherwise the call falls back to the underlying realm.Client implementation NOTE: this may panic if the underlying realm.Client is left undefined

type TelemetryService

type TelemetryService struct {
	telemetry.Service
	TrackEventFn func(eventType telemetry.EventType, data ...telemetry.EventData)
	CloseFn      func()
}

TelemetryService is a mocked telemetry service

func (TelemetryService) Close

func (s TelemetryService) Close()

Close calls the mocked Close implementation if provided, otherwise the call falls back to the underlying telemetry.Service implementation. NOTE: this may panic if the underlying telemetry.Service is left undefined

func (TelemetryService) TrackEvent

func (s TelemetryService) TrackEvent(eventType telemetry.EventType, data ...telemetry.EventData)

TrackEvent calls the mocked TrackEvent implementation if provided, otherwise the call falls back to the underlying telemetry.Service implementation. NOTE: this may panic if the underlying telemetry.Service is left undefined

type UIOptions

type UIOptions struct {
	AutoConfirm bool
	UseColors   bool
	UseJSON     bool
}

UIOptions are the options to configure the mock terminal UI

Jump to

Keyboard shortcuts

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