components

package
v0.36.0 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2022 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TEST_NAME_ENV_VAR = "TEST_NAME"
	SANDBOX_ENV_VAR   = "SANDBOX"
)

Variables

This section is empty.

Functions

func Contains

func Contains(target string) *matcher

func Equals

func Equals(target string) *matcher

func HandleSnapshots

func HandleSnapshots(paths Paths, logf logf, test *IntegrationTest, mode Mode) error

func KeyPressDelay

func KeyPressDelay() int

this is the delay in milliseconds between keypresses defaults to zero

func NotContains

func NotContains(target 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),
	mode Mode,
	keyPressDelay int,
	maxAttempts int,
) error

func TestNameFromFilePath

func TestNameFromFilePath(path string) string

Types

type Assert

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

func NewAssert

func NewAssert(gui integrationTypes.GuiDriver) *Assert

func (*Assert) AtLeastOneCommit

func (self *Assert) AtLeastOneCommit()

func (*Assert) CommitCount

func (self *Assert) CommitCount(expectedCount int)

func (*Assert) CurrentBranchName

func (self *Assert) CurrentBranchName(expectedViewName string)

func (*Assert) CurrentViewName

func (self *Assert) CurrentViewName(expectedViewName string)

func (*Assert) CurrentWindowName

func (self *Assert) CurrentWindowName(expectedWindowName string)

func (*Assert) Fail

func (self *Assert) Fail(message string)

for when you just want to fail the test yourself

func (*Assert) InAlert

func (self *Assert) InAlert()

func (*Assert) InConfirm

func (self *Assert) InConfirm()

func (*Assert) InListContext

func (self *Assert) InListContext()

func (*Assert) InMenu

func (self *Assert) InMenu()

func (*Assert) InPrompt

func (self *Assert) InPrompt()

func (*Assert) MatchCurrentViewContent

func (self *Assert) MatchCurrentViewContent(matcher *matcher)

func (*Assert) MatchCurrentViewTitle

func (self *Assert) MatchCurrentViewTitle(matcher *matcher)

func (*Assert) MatchHeadCommitMessage

func (self *Assert) MatchHeadCommitMessage(matcher *matcher)

func (*Assert) MatchMainViewContent

func (self *Assert) MatchMainViewContent(matcher *matcher)

func (*Assert) MatchSecondaryViewContent

func (self *Assert) MatchSecondaryViewContent(matcher *matcher)

func (*Assert) MatchSelectedLine

func (self *Assert) MatchSelectedLine(matcher *matcher)

func (*Assert) MatchViewContent

func (self *Assert) MatchViewContent(viewName string, matcher *matcher)

func (*Assert) StashCount

func (self *Assert) StashCount(expectedCount int)

func (*Assert) WorkingTreeFileCount

func (self *Assert) WorkingTreeFileCount(expectedCount int)

type Input

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

func NewInput

func NewInput(gui integrationTypes.GuiDriver, keys config.KeybindingConfig, assert *Assert, pushKeyDelay int) *Input

func (*Input) Cancel

func (self *Input) Cancel()

i.e. pressing escape

func (*Input) Confirm

func (self *Input) Confirm()

i.e. pressing enter

func (*Input) ContinueMerge

func (self *Input) ContinueMerge()

func (*Input) ContinueRebase

func (self *Input) ContinueRebase()

func (*Input) Enter

func (self *Input) Enter()

i.e. same as Confirm

func (*Input) Log

func (self *Input) Log(message string)

func (*Input) LogUI

func (self *Input) LogUI(message string)

func (*Input) NavigateToListItemContainingText

func (self *Input) NavigateToListItemContainingText(text string)

this will look for a list item in the current panel and if it finds it, it will enter the keypresses required to navigate to it. The test will fail if: - the user is not in a list item - no list item is found containing the given text - multiple list items are found containing the given text in the initial page of items

NOTE: this currently assumes that ViewBufferLines returns all the lines that can be accessed. If this changes in future, we'll need to update this code to first attempt to find the item in the current page and failing that, jump to the top of the view and iterate through all of it, looking for the item.

func (*Input) NextItem

func (self *Input) NextItem()

i.e. pressing down arrow

func (*Input) PressKeys

func (self *Input) PressKeys(keyStrs ...string)

key is something like 'w' or '<space>'. It's best not to pass a direct value, but instead to go through the default user config to get a more meaningful key name

func (*Input) PreviousItem

func (self *Input) PreviousItem()

i.e. pressing up arrow

func (*Input) PrimaryAction

func (self *Input) PrimaryAction()

i.e. pressing space

func (*Input) ProceedWhenAsked

func (self *Input) ProceedWhenAsked(matcher *matcher)

func (*Input) SwitchToBranchesWindow

func (self *Input) SwitchToBranchesWindow()

func (*Input) SwitchToCommitsWindow

func (self *Input) SwitchToCommitsWindow()

func (*Input) SwitchToFilesWindow

func (self *Input) SwitchToFilesWindow()

func (*Input) SwitchToStashWindow

func (self *Input) SwitchToStashWindow()

func (*Input) SwitchToStatusWindow

func (self *Input) SwitchToStatusWindow()

func (*Input) Type

func (self *Input) Type(content string)

func (*Input) Wait

func (self *Input) Wait(milliseconds int)

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

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

I want access to all contexts, the model, the ability to press a key, the ability to log,

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 MockTestingT

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

func (*MockTestingT) Errorf

func (self *MockTestingT) Errorf(format string, args ...interface{})

type Mode

type Mode int
const (
	// Default: if a snapshot test fails, the we'll be asked whether we want to update it
	ASK_TO_UPDATE_SNAPSHOT Mode = iota
	// fails the test if the snapshots don't match
	CHECK_SNAPSHOT
	// runs the test and updates the snapshot
	UPDATE_SNAPSHOT
	// This just makes use of the setup step of the test to get you into
	// a lazygit session. Then you'll be able to do whatever you want. Useful
	// when you want to test certain things without needing to manually set
	// up the situation yourself.
	// fails the test if the snapshots don't match
	SANDBOX
)

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(shell *Shell, input *Input, assert *Assert, 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 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) *Shell

func (*Shell) Checkout

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

func (*Shell) Commit

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

func (*Shell) CreateDir

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

func (*Shell) CreateFile

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

func (*Shell) CreateFileAndAdd

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

convenience method for creating a file and adding it

func (*Shell) CreateNCommits

func (s *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 (s *Shell) EmptyCommit(message string) *Shell

func (*Shell) GitAdd

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

func (*Shell) GitAddAll

func (s *Shell) GitAddAll() *Shell

func (*Shell) Merge

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

func (*Shell) NewBranch

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

func (*Shell) RunCommand

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

func (*Shell) StashWithMessage

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

func (*Shell) UpdateFile

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

func (*Shell) UpdateFileAndAdd

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

convenience method for updating a file and adding it

type Snapshotter

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

func NewSnapshotter

func NewSnapshotter(
	paths Paths,
	logf logf,
	test *IntegrationTest,
	mode Mode,
) *Snapshotter

Jump to

Keyboard shortcuts

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