system

package
v0.0.0-...-b93a6bd Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2020 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package system contains functions using, importing, saving, and destroying systems. Each tests usually consists of use/create and close/destroy operations, this module makes that easier.

Using existing systems

Either Use or UseOrImport (when system info is provided in the config or the flags) will return a reference to an existing system.

Importing into new system

Either Import or UseOrImport (when no system info is provided) will import and return a reference to the new system.

Destroying systems

Destroy will destroy the system when called, therefore, is mostly useful when used together with a defer statement:

defer system.Destroy(t, s)

Saving systems

Save will create write a config file with the system info in it for later use:

defer system.Save(t, s)

Polymorphic destroying and saving

To avoid having to change the test code each time we want to destroy and/or save a system, the Finish function will take care of deciding what to do based on the provided configuration and flags:

defer system.Finish(t, s)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Destroy

func Destroy(t cbtest.T, system *EphemeralSystem)

Destroy destroys the remote system instance, as well as the local folder. Only systems that are managed by this module will be destroyed, external systems will not. Panics on failure.

func DestroyE

func DestroyE(t cbtest.T, system *EphemeralSystem) error

DestroyE destroys the remote system instance, as well as the local folder. Only systems that are managed by this module will be destroyed, external systems will not. Returns error on failure.

func Finish

func Finish(t cbtest.T, s *EphemeralSystem)

Finish closes the given system. Real behavior depends on the config and the flags passed to cbtest. For instance, and external system will never be destroyed; and an imported system will always be destroyed unless we requested its configuration to be saved for later use. Panics on error.

func FinishE

func FinishE(t cbtest.T, s *EphemeralSystem) error

FinishE closes the given system. Real behavior depends on the config and the flags passed to cbtest. For instance, and external system will never be destroyed; and an imported system will always be destroyed unless we requested its configuration to be saved for later use. Returns error on failure.

func Save

func Save(t cbtest.T, system *EphemeralSystem)

Save saves the system config for later use with UseSystem. Panics on failure.

func SaveE

func SaveE(t cbtest.T, system *EphemeralSystem) error

SaveE saves the system config for later use with UseSystem. Returns error on failure.

Types

type EphemeralSystem

type EphemeralSystem struct {
	// contains filtered or unexported fields
}

EphemeralSystem represents a system that exists solely for testing.

func Import

func Import(t cbtest.T, systemPath string, extraPaths ...string) *EphemeralSystem

Import imports the system given by merging the base system given by `systemPath` and the extra files given by each of the `extraPaths`. Panics on failure.

func ImportE

func ImportE(t cbtest.T, systemPath string, extraPaths ...string) (*EphemeralSystem, error)

ImportE imports the system given by merging the base system given by `systemPath` and the extra files given by each of the `extraPaths`. Returns error on failure.

func ImportWithConfig

func ImportWithConfig(t cbtest.T, provider provider.Config, systemPath string, extraPaths ...string) *EphemeralSystem

ImportWithConfig imports the system given by merging the base system given by `systemPath` and the extra files given by each of the `extraPaths` into the platform instance given by the config. Panics on error.

func ImportWithConfigE

func ImportWithConfigE(t cbtest.T, provider provider.Config, systemPath string, extraPaths ...string) (*EphemeralSystem, error)

ImportWithConfigE imports the system given by merging the base system given by `systemPath` and the extra files given by each of the `extraPaths` into the platform instance given by the config. Returns error on failure.

func Use

func Use(t cbtest.T) *EphemeralSystem

Use uses the external (not managed by cbtest) system given by the config flag. External systems are never destroyed automatically. Panics on failure.

func UseE

func UseE(t cbtest.T) (*EphemeralSystem, error)

UseE uses the external (not managed by cbtest) system given by the config flag. External systems are never destroyed automatically. Returns error on failure.

func UseOrImport

func UseOrImport(t cbtest.T, systemPath string, extraPaths ...string) *EphemeralSystem

UseOrImport tries to use an existing system (given by config or flags), if that fails, it tries to import the system instead. Panics on failure.

func UseOrImportE

func UseOrImportE(t cbtest.T, systemPath string, extraPaths ...string) (*EphemeralSystem, error)

UseOrImportE tries to use an existing system (given by config or flags), if that fails, it tries to import the system instead. Returns error on failure.

func UseOrImportWithConfig

func UseOrImportWithConfig(t cbtest.T, provider provider.Config, systemPath string, extraPaths ...string) *EphemeralSystem

UseOrImportWithConfig tries to use an existing system (given by config), if that fails, it tries to import the system instead. Panics on failure.

func UseOrImportWithConfigE

func UseOrImportWithConfigE(t cbtest.T, provider provider.Config, systemPath string, extraPaths ...string) (*EphemeralSystem, error)

UseOrImportWithConfigE tries to use an existing system (given by config), if that fails, it tries to import the system instead. Returns error on failure.

func UseWithConfig

func UseWithConfig(t cbtest.T, provider provider.Config) *EphemeralSystem

UseWithConfig uses the external (not managed by cbtest) system given by the config. External systems are never destroyed automatically. Panics on error.

func UseWithConfigE

func UseWithConfigE(t cbtest.T, provider provider.Config) (*EphemeralSystem, error)

UseWithConfigE uses the external (not managed by cbtest) system given by the config. External systems are never destroyed automatically. Returns error on failure.

func (*EphemeralSystem) Client

func (es *EphemeralSystem) Client(t cbtest.T) *cb.DevClient

Client returns a dev client that can be used for accessing this system. This function implements the provider.Client interface. Panics on failure.

func (*EphemeralSystem) ClientE

func (es *EphemeralSystem) ClientE(t cbtest.T) (*cb.DevClient, error)

ClientE returns a dev client that can be used for accessing this system. This function implements the provider.Client interface. Returns error on failure.

func (*EphemeralSystem) Config

func (es *EphemeralSystem) Config(t cbtest.T) *config.Config

Config returns the config that was used for creating this system. This function implements the provider.Config interface. Panics on failure.

func (*EphemeralSystem) IsExternal

func (es *EphemeralSystem) IsExternal() bool

IsExternal returns if the ephemeral system is an external one.

func (*EphemeralSystem) LocalPath

func (es *EphemeralSystem) LocalPath() string

LocalPath returns the path where the local system is located.

func (*EphemeralSystem) MessagingURL

func (es *EphemeralSystem) MessagingURL() string

MessagingURL returns the messaging url that hosts this system.

func (*EphemeralSystem) PlatformURL

func (es *EphemeralSystem) PlatformURL() string

PlatformURL returns the platform url that hosts this system.

func (*EphemeralSystem) RemoteURL

func (es *EphemeralSystem) RemoteURL() string

RemoteURL returns the URL where the remote system is running.

func (*EphemeralSystem) SystemKey

func (es *EphemeralSystem) SystemKey() string

SystemKey returns the system key corresponding to this ephemeral system.

func (*EphemeralSystem) SystemSecret

func (es *EphemeralSystem) SystemSecret() string

SystemSecret returns the system secret corresponding to this ephemeral system.

Jump to

Keyboard shortcuts

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