components

package
v0.37.0 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2023 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TEST_NAME_ENV_VAR = "TEST_NAME"
	SANDBOX_ENV_VAR   = "SANDBOX"
)
View Source
const IS_SELECTED_RULE_NAME = "is selected"

Variables

This section is empty.

Functions

func Anything added in v0.37.0

func Anything() *matcher

this matcher has no rules meaning it always passes the test. Use this when you don't care what value you're dealing with.

func Contains

func Contains(target string) *matcher

func DoesNotContain added in v0.37.0

func DoesNotContain(target string) *matcher

func Equals

func Equals(target string) *matcher

func KeyPressDelay

func KeyPressDelay() int

this is the delay in milliseconds between keypresses defaults to zero

func MatchesRegexp added in v0.37.0

func MatchesRegexp(target string) *matcher

func NewMatcher added in v0.37.0

func NewMatcher(name string, testFn func(string) (bool, string)) *matcher

func RunTests

func RunTests(
	tests []*IntegrationTest,
	logf func(format string, formatArgs ...interface{}),
	runCmd func(cmd *exec.Cmd) error,
	testWrapper func(test *IntegrationTest, f func() error),
	sandbox bool,
	keyPressDelay int,
	maxAttempts int,
) error

func TestNameFromFilePath

func TestNameFromFilePath(path string) string

Types

type Actions added in v0.37.0

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

for running common actions

func (*Actions) ContinueMerge added in v0.37.0

func (self *Actions) ContinueMerge()

func (*Actions) ContinueRebase added in v0.37.0

func (self *Actions) ContinueRebase()

type AlertDriver added in v0.37.0

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

func (*AlertDriver) Cancel added in v0.37.0

func (self *AlertDriver) Cancel()

func (*AlertDriver) Confirm added in v0.37.0

func (self *AlertDriver) Confirm()

func (*AlertDriver) Content added in v0.37.0

func (self *AlertDriver) Content(expected *matcher) *AlertDriver

asserts that the alert view has the expected content

func (*AlertDriver) Title added in v0.37.0

func (self *AlertDriver) Title(expected *matcher) *AlertDriver

asserts that the alert view has the expected title

type CommitMessagePanelDriver added in v0.37.0

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

func (*CommitMessagePanelDriver) AddNewline added in v0.37.0

func (*CommitMessagePanelDriver) Cancel added in v0.37.0

func (self *CommitMessagePanelDriver) Cancel()

func (*CommitMessagePanelDriver) Clear added in v0.37.0

func (*CommitMessagePanelDriver) Confirm added in v0.37.0

func (self *CommitMessagePanelDriver) Confirm()

func (*CommitMessagePanelDriver) InitialText added in v0.37.0

func (self *CommitMessagePanelDriver) InitialText(expected *matcher) *CommitMessagePanelDriver

asserts on the text initially present in the prompt

func (*CommitMessagePanelDriver) Type added in v0.37.0

type ConfirmationDriver added in v0.37.0

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

func (*ConfirmationDriver) Cancel added in v0.37.0

func (self *ConfirmationDriver) Cancel()

func (*ConfirmationDriver) Confirm added in v0.37.0

func (self *ConfirmationDriver) Confirm()

func (*ConfirmationDriver) Content added in v0.37.0

func (self *ConfirmationDriver) Content(expected *matcher) *ConfirmationDriver

asserts that the confirmation view has the expected content

func (*ConfirmationDriver) Title added in v0.37.0

func (self *ConfirmationDriver) Title(expected *matcher) *ConfirmationDriver

asserts that the confirmation view has the expected title

type FileSystem added in v0.37.0

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

func (*FileSystem) FileContent added in v0.37.0

func (self *FileSystem) FileContent(path string, matcher *matcher)

Asserts that the file at the given path has the given content

func (*FileSystem) PathNotPresent added in v0.37.0

func (self *FileSystem) PathNotPresent(path string)

This does _not_ check the files panel, it actually checks the filesystem

func (*FileSystem) PathPresent added in v0.37.0

func (self *FileSystem) PathPresent(path string)

This does _not_ check the files panel, it actually checks the filesystem

type Git added in v0.37.0

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

func (*Git) CurrentBranchName added in v0.37.0

func (self *Git) CurrentBranchName(expectedName string) *Git

type IntegrationTest

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

func NewIntegrationTest

func NewIntegrationTest(args NewIntegrationTestArgs) *IntegrationTest

func (*IntegrationTest) Description

func (self *IntegrationTest) Description() string

func (*IntegrationTest) ExtraCmdArgs

func (self *IntegrationTest) ExtraCmdArgs() string

func (*IntegrationTest) Name

func (self *IntegrationTest) Name() string

func (*IntegrationTest) Run

func (*IntegrationTest) SetupConfig

func (self *IntegrationTest) SetupConfig(config *config.AppConfig)

func (*IntegrationTest) SetupRepo

func (self *IntegrationTest) SetupRepo(shell *Shell)

func (*IntegrationTest) Skip

func (self *IntegrationTest) Skip() bool
type MenuDriver struct {
	// contains filtered or unexported fields
}
func (self *MenuDriver) Cancel()
func (self *MenuDriver) Confirm()
func (self *MenuDriver) Select(option *matcher) *MenuDriver
func (self *MenuDriver) Title(expected *matcher) *MenuDriver

asserts that the popup has the expected title

type NewIntegrationTestArgs

type NewIntegrationTestArgs struct {
	// Briefly describes what happens in the test and what it's testing for
	Description string
	// prepares a repo for testing
	SetupRepo func(shell *Shell)
	// takes a config and mutates. The mutated context will end up being passed to the gui
	SetupConfig func(config *config.AppConfig)
	// runs the test
	Run func(t *TestDriver, keys config.KeybindingConfig)
	// additional args passed to lazygit
	ExtraCmdArgs string
	// for when a test is flakey
	Skip bool
}

type Paths

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

convenience struct for easily getting directories within our test directory. We have one test directory for each test, found in test/integration_new.

func NewPaths

func NewPaths(root string) Paths

func (Paths) Actual

func (self Paths) Actual() string

when a test first runs, it's situated in a repo called 'repo' within this directory. In its setup step, the test is allowed to create other repos alongside the 'repo' repo in this directory, for example, creating remotes or repos to add as submodules.

func (Paths) ActualRepo

func (self Paths) ActualRepo() string

this is the 'repo' directory within the 'actual' directory, where a lazygit test will start within.

func (Paths) Config

func (self Paths) Config() string

func (Paths) Expected

func (self Paths) Expected() string

When an integration test first runs, we copy everything in the 'actual' directory, and copy it into the 'expected' directory so that future runs can be compared against what we expect.

func (Paths) Root

func (self Paths) Root() string
type Popup struct {
	// contains filtered or unexported fields
}

func (*Popup) Alert added in v0.37.0

func (self *Popup) Alert() *AlertDriver

func (*Popup) CommitMessagePanel added in v0.37.0

func (self *Popup) CommitMessagePanel() *CommitMessagePanelDriver

func (*Popup) Confirmation added in v0.37.0

func (self *Popup) Confirmation() *ConfirmationDriver

func (*Popup) Menu added in v0.37.0

func (self *Popup) Menu() *MenuDriver

func (*Popup) Prompt added in v0.37.0

func (self *Popup) Prompt() *PromptDriver

type PromptDriver added in v0.37.0

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

func (*PromptDriver) Cancel added in v0.37.0

func (self *PromptDriver) Cancel()

func (*PromptDriver) Clear added in v0.37.0

func (self *PromptDriver) Clear() *PromptDriver

func (*PromptDriver) Confirm added in v0.37.0

func (self *PromptDriver) Confirm()

func (*PromptDriver) ConfirmFirstSuggestion added in v0.37.0

func (self *PromptDriver) ConfirmFirstSuggestion()

func (*PromptDriver) ConfirmSuggestion added in v0.37.0

func (self *PromptDriver) ConfirmSuggestion(matcher *matcher)

func (*PromptDriver) InitialText added in v0.37.0

func (self *PromptDriver) InitialText(expected *matcher) *PromptDriver

asserts on the text initially present in the prompt

func (*PromptDriver) SuggestionLines added in v0.37.0

func (self *PromptDriver) SuggestionLines(matchers ...*matcher) *PromptDriver

func (*PromptDriver) SuggestionTopLines added in v0.37.0

func (self *PromptDriver) SuggestionTopLines(matchers ...*matcher) *PromptDriver

func (*PromptDriver) Title added in v0.37.0

func (self *PromptDriver) Title(expected *matcher) *PromptDriver

asserts that the popup has the expected title

func (*PromptDriver) Type added in v0.37.0

func (self *PromptDriver) Type(value string) *PromptDriver

type Shell

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

this is for running shell commands, mostly for the sake of setting up the repo but you can also run the commands from within lazygit to emulate things happening in the background.

func NewShell

func NewShell(dir string, fail func(string)) *Shell

func (*Shell) Checkout

func (self *Shell) Checkout(name string) *Shell

func (*Shell) CloneIntoRemote added in v0.37.0

func (self *Shell) CloneIntoRemote(name string) *Shell

creates a clone of the repo in a sibling directory and adds the clone as a remote, then fetches it.

func (*Shell) Commit

func (self *Shell) Commit(message string) *Shell

func (*Shell) CreateDir

func (self *Shell) CreateDir(path string) *Shell

func (*Shell) CreateFile

func (self *Shell) CreateFile(path string, content string) *Shell

func (*Shell) CreateFileAndAdd

func (self *Shell) CreateFileAndAdd(fileName string, fileContents string) *Shell

convenience method for creating a file and adding it

func (*Shell) CreateNCommits

func (self *Shell) CreateNCommits(n int) *Shell

creates commits 01, 02, 03, ..., n with a new file in each The reason for padding with zeroes is so that it's easier to do string matches on the commit messages when there are many of them

func (*Shell) EmptyCommit

func (self *Shell) EmptyCommit(message string) *Shell

func (*Shell) GitAdd

func (self *Shell) GitAdd(path string) *Shell

func (*Shell) GitAddAll

func (self *Shell) GitAddAll() *Shell

func (*Shell) HardReset added in v0.37.0

func (self *Shell) HardReset(ref string) *Shell

func (*Shell) Merge

func (self *Shell) Merge(name string) *Shell

func (*Shell) NewBranch

func (self *Shell) NewBranch(name string) *Shell

func (*Shell) RemoveRemoteBranch added in v0.37.0

func (self *Shell) RemoveRemoteBranch(remoteName string, branch string) *Shell

func (*Shell) RunCommand

func (self *Shell) RunCommand(cmdStr string) *Shell

func (*Shell) RunShellCommand added in v0.37.0

func (self *Shell) RunShellCommand(cmdStr string) *Shell

func (*Shell) RunShellCommandExpectError added in v0.37.0

func (self *Shell) RunShellCommandExpectError(cmdStr string) *Shell

func (*Shell) SetBranchUpstream added in v0.37.0

func (self *Shell) SetBranchUpstream(branch string, upstream string) *Shell

e.g. branch: 'master', upstream: 'origin/master'

func (*Shell) SetConfig added in v0.37.0

func (self *Shell) SetConfig(key string, value string) *Shell

func (*Shell) StashWithMessage

func (self *Shell) StashWithMessage(message string) *Shell

func (*Shell) UpdateFile

func (self *Shell) UpdateFile(path string, content string) *Shell

func (*Shell) UpdateFileAndAdd

func (self *Shell) UpdateFileAndAdd(fileName string, fileContents string) *Shell

convenience method for updating a file and adding it

type TestDriver added in v0.37.0

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

func NewTestDriver added in v0.37.0

func NewTestDriver(gui integrationTypes.GuiDriver, shell *Shell, keys config.KeybindingConfig, pushKeyDelay int) *TestDriver

func (*TestDriver) Actions added in v0.37.0

func (self *TestDriver) Actions() *Actions

func (*TestDriver) ExpectClipboard added in v0.37.0

func (self *TestDriver) ExpectClipboard(matcher *matcher)

func (*TestDriver) ExpectPopup added in v0.37.0

func (self *TestDriver) ExpectPopup() *Popup

for interacting with popups

func (*TestDriver) ExpectToast added in v0.37.0

func (self *TestDriver) ExpectToast(matcher *matcher)

func (*TestDriver) Fail added in v0.37.0

func (self *TestDriver) Fail(message string)

for when you just want to fail the test yourself. This runs callbacks to ensure we render the error after closing the gui.

func (*TestDriver) FileSystem added in v0.37.0

func (self *TestDriver) FileSystem() *FileSystem

for making assertions on the file system

func (*TestDriver) Git added in v0.37.0

func (self *TestDriver) Git() *Git

for making assertions through git itself

func (*TestDriver) Log added in v0.37.0

func (self *TestDriver) Log(message string)

func (*TestDriver) LogUI added in v0.37.0

func (self *TestDriver) LogUI(message string)

func (*TestDriver) Shell added in v0.37.0

func (self *TestDriver) Shell() *Shell

allows the user to run shell commands during the test to emulate background activity

func (*TestDriver) Views added in v0.37.0

func (self *TestDriver) Views() *Views

for making assertions on lazygit views

func (*TestDriver) Wait added in v0.37.0

func (self *TestDriver) Wait(milliseconds int)

for when you want to allow lazygit to process something before continuing

type ViewDriver added in v0.37.0

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

func (*ViewDriver) Content added in v0.37.0

func (self *ViewDriver) Content(matcher *matcher) *ViewDriver

asserts on the content of the view i.e. the stuff within the view's frame.

func (*ViewDriver) Focus added in v0.37.0

func (self *ViewDriver) Focus() *ViewDriver

focus the view (assumes the view is a side-view that can be focused via a keybinding)

func (*ViewDriver) IsEmpty added in v0.37.0

func (self *ViewDriver) IsEmpty() *ViewDriver

returns true if the view is a list view and it contains no items

func (*ViewDriver) IsFocused added in v0.37.0

func (self *ViewDriver) IsFocused() *ViewDriver

asserts that the view is focused

func (*ViewDriver) LineCount added in v0.37.0

func (self *ViewDriver) LineCount(expectedCount int) *ViewDriver

func (*ViewDriver) Lines added in v0.37.0

func (self *ViewDriver) Lines(matchers ...*matcher) *ViewDriver

asserts that the view has lines matching the given matchers. One matcher must be passed for each line. If you only care about the top n lines, use the TopLines method instead.

func (*ViewDriver) NavigateToListItem added in v0.37.0

func (self *ViewDriver) NavigateToListItem(matcher *matcher) *ViewDriver

func (*ViewDriver) Press added in v0.37.0

func (self *ViewDriver) Press(keyStr string) *ViewDriver

func (*ViewDriver) PressEnter added in v0.37.0

func (self *ViewDriver) PressEnter() *ViewDriver

i.e. pressing space

func (*ViewDriver) PressEscape added in v0.37.0

func (self *ViewDriver) PressEscape() *ViewDriver

i.e. pressing escape

func (*ViewDriver) PressPrimaryAction added in v0.37.0

func (self *ViewDriver) PressPrimaryAction() *ViewDriver

i.e. pressing space

func (*ViewDriver) SelectNextItem added in v0.37.0

func (self *ViewDriver) SelectNextItem() *ViewDriver

i.e. pressing down arrow

func (*ViewDriver) SelectPreviousItem added in v0.37.0

func (self *ViewDriver) SelectPreviousItem() *ViewDriver

i.e. pressing up arrow

func (*ViewDriver) SelectedLine added in v0.37.0

func (self *ViewDriver) SelectedLine(matcher *matcher) *ViewDriver

asserts on the selected line of the view

func (*ViewDriver) SelectedLineIdx added in v0.37.0

func (self *ViewDriver) SelectedLineIdx(expected int) *ViewDriver

asserts on the index of the selected line. 0 is the first index, representing the line at the top of the view.

func (*ViewDriver) Tap added in v0.37.0

func (self *ViewDriver) Tap(f func()) *ViewDriver

for when you want to make some assertion unrelated to the current view without breaking the method chain

func (*ViewDriver) Title added in v0.37.0

func (self *ViewDriver) Title(expected *matcher) *ViewDriver

asserts that the view has the expected title

func (*ViewDriver) TopLines added in v0.37.0

func (self *ViewDriver) TopLines(matchers ...*matcher) *ViewDriver

asserts that the view has lines matching the given matchers. So if three matchers are passed, we only check the first three lines of the view. This method is convenient when you have a list of commits but you only want to assert on the first couple of commits.

type Views added in v0.37.0

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

func (*Views) AppStatus added in v0.37.0

func (self *Views) AppStatus() *ViewDriver

func (*Views) Branches added in v0.37.0

func (self *Views) Branches() *ViewDriver

func (*Views) CommitFiles added in v0.37.0

func (self *Views) CommitFiles() *ViewDriver

func (*Views) CommitMessage added in v0.37.0

func (self *Views) CommitMessage() *ViewDriver

func (*Views) Commits added in v0.37.0

func (self *Views) Commits() *ViewDriver

func (*Views) Confirmation added in v0.37.0

func (self *Views) Confirmation() *ViewDriver

func (*Views) Files added in v0.37.0

func (self *Views) Files() *ViewDriver

func (*Views) Information added in v0.37.0

func (self *Views) Information() *ViewDriver

func (*Views) Main added in v0.37.0

func (self *Views) Main() *ViewDriver

func (*Views) Menu added in v0.37.0

func (self *Views) Menu() *ViewDriver

func (*Views) MergeConflicts added in v0.37.0

func (self *Views) MergeConflicts() *ViewDriver

func (*Views) ReflogCommits added in v0.37.0

func (self *Views) ReflogCommits() *ViewDriver

func (*Views) RemoteBranches added in v0.37.0

func (self *Views) RemoteBranches() *ViewDriver

func (*Views) Secondary added in v0.37.0

func (self *Views) Secondary() *ViewDriver

func (*Views) Staging added in v0.37.0

func (self *Views) Staging() *ViewDriver

func (*Views) StagingSecondary added in v0.37.0

func (self *Views) StagingSecondary() *ViewDriver

func (*Views) Stash added in v0.37.0

func (self *Views) Stash() *ViewDriver

func (*Views) Status added in v0.37.0

func (self *Views) Status() *ViewDriver

func (*Views) SubCommits added in v0.37.0

func (self *Views) SubCommits() *ViewDriver

func (*Views) Submodules added in v0.37.0

func (self *Views) Submodules() *ViewDriver

func (*Views) Suggestions added in v0.37.0

func (self *Views) Suggestions() *ViewDriver

func (*Views) Tags added in v0.37.0

func (self *Views) Tags() *ViewDriver

Jump to

Keyboard shortcuts

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