e2e

package
v0.0.0-...-7426b64 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: BSD-3-Clause Imports: 40 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Bash Shell = "bash"
	Zsh        = "zsh"
	Tcsh       = "tcsh"
	Fish       = "fish"
	Cmd        = "cmd.exe"
)
View Source
const CommitIDNotChecked = "00000000-0000-0000-0000-000000000000"

CommitIDNotChecked is to satisfy state tool requiring commit ID's, while also making explicit that this test does not test anything related to commit ID's.

Variables

View Source
var (
	PersistentUsername string
	PersistentPassword string
	PersistentToken    string

	RuntimeSourcingTimeout = 3 * time.Minute
)
View Source
var (
	RuntimeSourcingTimeoutOpt = termtest.OptExpectTimeout(3 * time.Minute)
)

Functions

func QuoteCommand

func QuoteCommand(shell Shell, args ...string) string

QuoteCommand constructs and returns a command line string from the given list of arguments. The returned string can be passed to the given shell for evaluation.

func RunningOnCI

func RunningOnCI() bool

Types

type Dirs

type Dirs struct {
	Base string
	// Config is where configuration files are stored
	Config string
	// Cache is the directory where cached files including downloaded artifacts are stored
	Cache string
	// Bin is the directory where executables are stored
	Bin string
	// Work is the working directory where the activestate.yaml file would live, and that is the PWD for tested console processes
	Work string
	// DefaultBin is the bin directory for our default installation
	DefaultBin string
	// SockRoot is the directory for the state service's socket file
	SockRoot string
	// HomeDir is used as the test user's home directory
	HomeDir string
	// TempDir is the directory where temporary files are stored
	TempDir string
}

Dirs represents directories that are temporarily created for this end-to-end testing session

func NewDirs

func NewDirs(base string) (*Dirs, error)

NewDirs creates all temporary directories

func (*Dirs) Close

func (d *Dirs) Close() error

Close removes the temporary directories

type Session

type Session struct {
	Dirs *Dirs
	Env  []string

	T           *testing.T
	Exe         string
	SvcExe      string
	ExecutorExe string
	// contains filtered or unexported fields
}

Session represents an end-to-end testing session during which several console process can be spawned and tested It provides a consistent environment (environment variables and temporary directories) that is shared by processes spawned during this session. The session is approximately the equivalent of a terminal session, with the main difference processes in this session are not spawned by a shell.

func New

func New(t *testing.T, retainDirs bool, extraEnv ...string) *Session

func NewNoPathUpdate

func NewNoPathUpdate(t *testing.T, retainDirs bool, extraEnv ...string) *Session

func (*Session) ClearCache

func (s *Session) ClearCache() error

func (*Session) Close

func (s *Session) Close() error

Close removes the temporary directory unless RetainDirs is specified

func (*Session) CommitID

func (s *Session) CommitID() string

CommitID is used to grab the current commit ID for the project in our working directory. For integration tests you should use this function instead of localcommit.Get() and pjfile.LegacyCommitID() as it is guaranteed to give a fresh result from disk, whereas the ones above use caching which tests don't like.

func (*Session) CopyExeToDir

func (s *Session) CopyExeToDir(from, to string) string

func (*Session) CreateNewUser

func (s *Session) CreateNewUser() *mono_models.UserEditable

func (*Session) DebugLogs

func (s *Session) DebugLogs() map[string]string

func (*Session) DebugLogsDump

func (s *Session) DebugLogsDump() string

func (*Session) DebugMessage

func (s *Session) DebugMessage(prefix string) string

func (*Session) DeleteUUIDProjects

func (s *Session) DeleteUUIDProjects(org string)

DeleteUUIDProjects indicates that all projects with UUID names (i.e. autogenerated) for the given org should be deleted when the session is closed. This should not be called from generic integration tests. Use NotifyProjectCreated() instead, because there could be race conditions if multiple platforms are creating and using UUID projects.

func (*Session) ExecutablePath

func (s *Session) ExecutablePath() string

ExecutablePath returns the path to the state tool that we want to test

func (*Session) IgnoreLogErrors

func (s *Session) IgnoreLogErrors()

IgnoreLogErrors disables log error checking after the session closes. Normally, logged errors automatically cause test failures, so calling this is needed for tests with expected errors.

func (*Session) InstallerLog

func (s *Session) InstallerLog() string

func (*Session) LogFiles

func (s *Session) LogFiles() []string

func (*Session) LoginAsPersistentUser

func (s *Session) LoginAsPersistentUser()

LoginAsPersistentUser is a common test case after which an integration test user should be logged in to the platform

func (*Session) LogoutUser

func (s *Session) LogoutUser()

func (*Session) NotifyProjectCreated

func (s *Session) NotifyProjectCreated(org, name string)

NotifyProjectCreated indicates that the given project was created on the Platform and needs to be deleted when the session is closed. This only needs to be called for projects created by PersistentUsername, not projects created by users created with CreateNewUser(). Created users' projects are auto-deleted.

func (*Session) PrepareActiveStateYAML

func (s *Session) PrepareActiveStateYAML(contents string)

PrepareActiveStateYAML creates an activestate.yaml in the session's work directory from the given YAML contents.

func (*Session) PrepareCommitIdFile

func (s *Session) PrepareCommitIdFile(commitID string)

func (*Session) PrepareFile

func (s *Session) PrepareFile(path, contents string)

PrepareFile writes a file to path with contents, expecting no error

func (*Session) PrepareProject

func (s *Session) PrepareProject(namespace, commitID string)

PrepareProject creates a very simple activestate.yaml file for the given org/project and, if a commit ID is given, an .activestate/commit file.

func (*Session) SetT

func (s *Session) SetT(t *testing.T)

func (*Session) SetupRCFile

func (s *Session) SetupRCFile()

func (*Session) SetupRCFileCustom

func (s *Session) SetupRCFileCustom(subshell subshell.SubShell)

func (*Session) Spawn

func (s *Session) Spawn(args ...string) *SpawnedCmd

Spawn spawns the state tool executable to be tested with arguments

func (*Session) SpawnCmd

func (s *Session) SpawnCmd(cmdName string, args ...string) *SpawnedCmd

SpawnCmd executes an executable in a pseudo-terminal for integration tests

func (*Session) SpawnCmdWithOpts

func (s *Session) SpawnCmdWithOpts(exe string, optSetters ...SpawnOptSetter) *SpawnedCmd

SpawnCmdWithOpts executes an executable in a pseudo-terminal for integration tests Arguments and other parameters can be specified by specifying SpawnOptSetter

func (*Session) SpawnShellWithOpts

func (s *Session) SpawnShellWithOpts(shell Shell, opts ...SpawnOptSetter) *SpawnedCmd

SpawnShellWithOpts spawns the given shell and options in interactive mode.

func (*Session) SpawnWithOpts

func (s *Session) SpawnWithOpts(opts ...SpawnOptSetter) *SpawnedCmd

SpawnWithOpts spawns the state tool executable to be tested with arguments

func (*Session) SvcLog

func (s *Session) SvcLog() string

type Shell

type Shell string

type SpawnOptSetter

type SpawnOptSetter func(opts *SpawnOpts)

func OptAppendEnv

func OptAppendEnv(env ...string) SpawnOptSetter

func OptArgs

func OptArgs(args ...string) SpawnOptSetter

func OptHideArgs

func OptHideArgs() SpawnOptSetter

func OptRunInsideShell

func OptRunInsideShell(v bool) SpawnOptSetter

func OptTermTest

func OptTermTest(opt ...termtest.SetOpt) SpawnOptSetter

func OptWD

func OptWD(wd string) SpawnOptSetter

type SpawnOpts

type SpawnOpts struct {
	Args           []string
	Env            []string
	Dir            string
	TermtestOpts   []termtest.SetOpt
	HideCmdArgs    bool
	RunInsideShell bool
}

func NewSpawnOpts

func NewSpawnOpts() SpawnOpts

type SpawnedCmd

type SpawnedCmd struct {
	*termtest.TermTest
	// contains filtered or unexported fields
}

func (*SpawnedCmd) Executable

func (s *SpawnedCmd) Executable() string

func (*SpawnedCmd) ExpectInput

func (s *SpawnedCmd) ExpectInput(opts ...termtest.SetExpectOpt) error

func (*SpawnedCmd) ExpectRe

func (s *SpawnedCmd) ExpectRe(v string, opts ...termtest.SetExpectOpt) error

ExpectRe takes a string rather than an already compiled regex, so that we can handle regex compilation failures through our error handling chain rather than have it fail on eg. a panic through regexp.MustCompile, or needing to manually error check it before sending it to ExpectRe.

func (*SpawnedCmd) Send

func (s *SpawnedCmd) Send(value string) error

func (*SpawnedCmd) SendEnter

func (s *SpawnedCmd) SendEnter() error

func (*SpawnedCmd) SendKeyDown

func (s *SpawnedCmd) SendKeyDown() error

func (*SpawnedCmd) SendKeyLeft

func (s *SpawnedCmd) SendKeyLeft() error

func (*SpawnedCmd) SendKeyRight

func (s *SpawnedCmd) SendKeyRight() error

func (*SpawnedCmd) SendKeyUp

func (s *SpawnedCmd) SendKeyUp() error

func (*SpawnedCmd) SendLine

func (s *SpawnedCmd) SendLine(value string) error

func (*SpawnedCmd) StrippedSnapshot

func (s *SpawnedCmd) StrippedSnapshot() string

StrippedSnapshot returns the snapshot with trimmed whitespace and stripped line endings Mainly intended for JSON parsing

func (*SpawnedCmd) Wait

func (s *SpawnedCmd) Wait() error

func (*SpawnedCmd) WorkDirectory

func (s *SpawnedCmd) WorkDirectory() string

Jump to

Keyboard shortcuts

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