Documentation ¶
Index ¶
- Constants
- Variables
- func InputDelay() int
- func NewTestEnvironment(rootDir string) []string
- func RunTests(args RunTestArgs) error
- func TestNameFromFilePath(path string) string
- type AlertDriver
- type CommitDescriptionPanelDriver
- func (self *CommitDescriptionPanelDriver) AddCoAuthor(author string) *CommitDescriptionPanelDriver
- func (self *CommitDescriptionPanelDriver) AddNewline() *CommitDescriptionPanelDriver
- func (self *CommitDescriptionPanelDriver) Cancel()
- func (self *CommitDescriptionPanelDriver) Content(expected *TextMatcher) *CommitDescriptionPanelDriver
- func (self *CommitDescriptionPanelDriver) GoToBeginning() *CommitDescriptionPanelDriver
- func (self *CommitDescriptionPanelDriver) SwitchToSummary() *CommitMessagePanelDriver
- func (self *CommitDescriptionPanelDriver) Title(expected *TextMatcher) *CommitDescriptionPanelDriver
- func (self *CommitDescriptionPanelDriver) Type(value string) *CommitDescriptionPanelDriver
- type CommitMessagePanelDriver
- func (self *CommitMessagePanelDriver) Cancel()
- func (self *CommitMessagePanelDriver) Clear() *CommitMessagePanelDriver
- func (self *CommitMessagePanelDriver) Close()
- func (self *CommitMessagePanelDriver) Confirm()
- func (self *CommitMessagePanelDriver) Content(expected *TextMatcher) *CommitMessagePanelDriver
- func (self *CommitMessagePanelDriver) InitialText(expected *TextMatcher) *CommitMessagePanelDriver
- func (self *CommitMessagePanelDriver) OpenCommitMenu() *CommitMessagePanelDriver
- func (self *CommitMessagePanelDriver) SelectNextMessage() *CommitMessagePanelDriver
- func (self *CommitMessagePanelDriver) SelectPreviousMessage() *CommitMessagePanelDriver
- func (self *CommitMessagePanelDriver) SwitchToDescription() *CommitDescriptionPanelDriver
- func (self *CommitMessagePanelDriver) SwitchToEditor()
- func (self *CommitMessagePanelDriver) Title(expected *TextMatcher) *CommitMessagePanelDriver
- func (self *CommitMessagePanelDriver) Type(value string) *CommitMessagePanelDriver
- type Common
- func (self *Common) AbortMerge()
- func (self *Common) AbortRebase()
- func (self *Common) AcknowledgeConflicts()
- func (self *Common) ConfirmDiscardLines()
- func (self *Common) ContinueMerge()
- func (self *Common) ContinueOnConflictsResolved()
- func (self *Common) ContinueRebase()
- func (self *Common) ResetBisect()
- func (self *Common) ResetCustomPatch()
- func (self *Common) SelectPatchOption(matcher *TextMatcher)
- type ConfirmationDriver
- func (self *ConfirmationDriver) Cancel()
- func (self *ConfirmationDriver) Confirm()
- func (self *ConfirmationDriver) Content(expected *TextMatcher) *ConfirmationDriver
- func (self *ConfirmationDriver) Title(expected *TextMatcher) *ConfirmationDriver
- func (self *ConfirmationDriver) Wait(milliseconds int) *ConfirmationDriver
- type FileSystem
- type Git
- type GitVersionRestriction
- type IntMatcher
- type IntegrationTest
- func (self *IntegrationTest) Description() string
- func (self *IntegrationTest) ExtraCmdArgs() []string
- func (self *IntegrationTest) ExtraEnvVars() map[string]string
- func (self *IntegrationTest) HeadlessDimensions() (int, int)
- func (self *IntegrationTest) IsDemo() bool
- func (self *IntegrationTest) Name() string
- func (self *IntegrationTest) RequiresHeadless() bool
- func (self *IntegrationTest) Run(gui integrationTypes.GuiDriver)
- func (self *IntegrationTest) SetupConfig(config *config.AppConfig)
- func (self *IntegrationTest) SetupRepo(shell *Shell)
- func (self *IntegrationTest) ShouldRunForGitVersion(version *git_commands.GitVersion) bool
- func (self *IntegrationTest) Skip() bool
- type Matcher
- type MenuDriver
- func (self *MenuDriver) Cancel()
- func (self *MenuDriver) Confirm() *MenuDriver
- func (self *MenuDriver) Filter(text string) *MenuDriver
- func (self *MenuDriver) LineCount(matcher *IntMatcher) *MenuDriver
- func (self *MenuDriver) Lines(matchers ...*TextMatcher) *MenuDriver
- func (self *MenuDriver) Select(option *TextMatcher) *MenuDriver
- func (self *MenuDriver) Tap(f func()) *MenuDriver
- func (self *MenuDriver) Title(expected *TextMatcher) *MenuDriver
- func (self *MenuDriver) Tooltip(option *TextMatcher) *MenuDriver
- func (self *MenuDriver) TopLines(matchers ...*TextMatcher) *MenuDriver
- func (self *MenuDriver) Wait(milliseconds int) *MenuDriver
- type NewIntegrationTestArgs
- type Paths
- type Popup
- func (self *Popup) Alert() *AlertDriver
- func (self *Popup) CommitDescriptionPanel() *CommitMessagePanelDriver
- func (self *Popup) CommitMessagePanel() *CommitMessagePanelDriver
- func (self *Popup) Confirmation() *ConfirmationDriver
- func (self *Popup) Menu() *MenuDriver
- func (self *Popup) Prompt() *PromptDriver
- type PromptDriver
- func (self *PromptDriver) Cancel()
- func (self *PromptDriver) Clear() *PromptDriver
- func (self *PromptDriver) Confirm()
- func (self *PromptDriver) ConfirmFirstSuggestion()
- func (self *PromptDriver) ConfirmSuggestion(matcher *TextMatcher)
- func (self *PromptDriver) InitialText(expected *TextMatcher) *PromptDriver
- func (self *PromptDriver) SuggestionLines(matchers ...*TextMatcher) *PromptDriver
- func (self *PromptDriver) SuggestionTopLines(matchers ...*TextMatcher) *PromptDriver
- func (self *PromptDriver) Title(expected *TextMatcher) *PromptDriver
- func (self *PromptDriver) Type(value string) *PromptDriver
- type RandomFile
- type RunTestArgs
- type SearchDriver
- type Shell
- func (self *Shell) AddFileInWorktree(worktreePath string) *Shell
- func (self *Shell) AddWorktree(base string, path string, newBranchName string) *Shell
- func (self *Shell) AddWorktreeCheckout(base string, path string) *Shell
- func (self *Shell) Chdir(path string) *Shell
- func (self *Shell) Checkout(name string) *Shell
- func (self *Shell) Clone(repoName string) *Shell
- func (self *Shell) CloneIntoRemote(name string) *Shell
- func (self *Shell) CloneIntoSubmodule(submoduleName string, submodulePath string) *Shell
- func (self *Shell) Commit(message string) *Shell
- func (self *Shell) ContinueMerge() *Shell
- func (self *Shell) CopyFile(source string, destination string) *Shell
- func (self *Shell) CopyHelpFile(source string, destination string) *Shell
- func (self *Shell) CreateAnnotatedTag(name string, message string, ref string) *Shell
- func (self *Shell) CreateDir(path string) *Shell
- func (self *Shell) CreateFile(path string, content string) *Shell
- func (self *Shell) CreateFileAndAdd(fileName string, fileContents string) *Shell
- func (self *Shell) CreateLightweightTag(name string, ref string) *Shell
- func (self *Shell) CreateNCommits(n int) *Shell
- func (self *Shell) CreateNCommitsStartingAt(n, startIndex int) *Shell
- func (self *Shell) CreateNCommitsWithRandomMessages(n int) *Shell
- func (self *Shell) CreateRepoHistory() *Shell
- func (self *Shell) DeleteFile(path string) *Shell
- func (self *Shell) DeleteFileAndAdd(fileName string) *Shell
- func (self *Shell) EmptyCommit(message string) *Shell
- func (self *Shell) EmptyCommitDaysAgo(message string, daysAgo int) *Shell
- func (self *Shell) EmptyCommitWithDate(message string, date string) *Shell
- func (self *Shell) GitAdd(path string) *Shell
- func (self *Shell) GitAddAll() *Shell
- func (self *Shell) HardReset(ref string) *Shell
- func (self *Shell) Init() *Shell
- func (self *Shell) MakeExecutable(path string) *Shell
- func (self *Shell) Merge(name string) *Shell
- func (self *Shell) NewBranch(name string) *Shell
- func (self *Shell) NewBranchFrom(name string, from string) *Shell
- func (self *Shell) PushBranch(upstream, branch string) *Shell
- func (self *Shell) RandomChangeCommit(message string) *Shell
- func (self *Shell) RemoveRemoteBranch(remoteName string, branch string) *Shell
- func (self *Shell) Revert(ref string) *Shell
- func (self *Shell) RunCommand(args []string) *Shell
- func (self *Shell) RunCommandExpectError(args []string) *Shell
- func (self *Shell) RunCommandWithEnv(args []string, env []string) *Shell
- func (self *Shell) RunShellCommand(cmdStr string) *Shell
- func (self *Shell) SetAuthor(authorName string, authorEmail string) *Shell
- func (self *Shell) SetBranchUpstream(branch string, upstream string) *Shell
- func (self *Shell) SetConfig(key string, value string) *Shell
- func (self *Shell) StartBisect(good string, bad string) *Shell
- func (self *Shell) Stash(message string) *Shell
- func (self *Shell) UpdateFile(path string, content string) *Shell
- func (self *Shell) UpdateFileAndAdd(fileName string, fileContents string) *Shell
- type TestDriver
- func (self *TestDriver) Common() *Common
- func (self *TestDriver) ExpectClipboard(matcher *TextMatcher)
- func (self *TestDriver) ExpectPopup() *Popup
- func (self *TestDriver) ExpectSearch() *SearchDriver
- func (self *TestDriver) ExpectToast(matcher *TextMatcher) *TestDriver
- func (self *TestDriver) Fail(message string)
- func (self *TestDriver) FileSystem() *FileSystem
- func (self *TestDriver) Git() *Git
- func (self *TestDriver) GlobalPress(keyStr string)
- func (self *TestDriver) Log(message string)
- func (self *TestDriver) LogUI(message string)
- func (self *TestDriver) SetCaption(caption string)
- func (self *TestDriver) SetCaptionPrefix(prefix string)
- func (self *TestDriver) Shell() *Shell
- func (self *TestDriver) Views() *Views
- func (self *TestDriver) Wait(milliseconds int)
- type TextMatcher
- func (self *TextMatcher) Contains(target string) *TextMatcher
- func (self *TextMatcher) DoesNotContain(target string) *TextMatcher
- func (self *TextMatcher) DoesNotContainAnyOf(targets []string) *TextMatcher
- func (self *TextMatcher) Equals(target string) *TextMatcher
- func (self *TextMatcher) IsSelected() *TextMatcher
- func (self *TextMatcher) MatchesRegexp(target string) *TextMatcher
- type ViewDriver
- func (self *ViewDriver) Click(x, y int) *ViewDriver
- func (self *ViewDriver) ContainsColoredText(fgColorStr string, text string) *ViewDriver
- func (self *ViewDriver) ContainsLines(matchers ...*TextMatcher) *ViewDriver
- func (self *ViewDriver) Content(matcher *TextMatcher) *ViewDriver
- func (self *ViewDriver) DoesNotContainColoredText(fgColorStr string, text string) *ViewDriver
- func (self *ViewDriver) FilterOrSearch(text string) *ViewDriver
- func (self *ViewDriver) Focus() *ViewDriver
- func (self *ViewDriver) IsEmpty() *ViewDriver
- func (self *ViewDriver) IsFocused() *ViewDriver
- func (self *ViewDriver) IsInvisible() *ViewDriver
- func (self *ViewDriver) IsVisible() *ViewDriver
- func (self *ViewDriver) LineCount(matcher *IntMatcher) *ViewDriver
- func (self *ViewDriver) Lines(matchers ...*TextMatcher) *ViewDriver
- func (self *ViewDriver) NavigateToLine(matcher *TextMatcher) *ViewDriver
- func (self *ViewDriver) Press(keyStr string) *ViewDriver
- func (self *ViewDriver) PressEnter() *ViewDriver
- func (self *ViewDriver) PressEscape() *ViewDriver
- func (self *ViewDriver) PressFast(keyStr string) *ViewDriver
- func (self *ViewDriver) PressPrimaryAction() *ViewDriver
- func (self *ViewDriver) PressTab() *ViewDriver
- func (self *ViewDriver) SelectNextItem() *ViewDriver
- func (self *ViewDriver) SelectPreviousItem() *ViewDriver
- func (self *ViewDriver) SelectedLine(matcher *TextMatcher) *ViewDriver
- func (self *ViewDriver) SelectedLineIdx(expected int) *ViewDriver
- func (self *ViewDriver) SelectedLines(matchers ...*TextMatcher) *ViewDriver
- func (self *ViewDriver) Self() *ViewDriver
- func (self *ViewDriver) SetCaption(caption string) *ViewDriver
- func (self *ViewDriver) SetCaptionPrefix(prefix string) *ViewDriver
- func (self *ViewDriver) Tap(f func()) *ViewDriver
- func (self *ViewDriver) Title(expected *TextMatcher) *ViewDriver
- func (self *ViewDriver) TopLines(matchers ...*TextMatcher) *ViewDriver
- func (self *ViewDriver) VisibleLines(matchers ...*TextMatcher) *ViewDriver
- func (self *ViewDriver) Wait(milliseconds int) *ViewDriver
- type Views
- func (self *Views) AppStatus() *ViewDriver
- func (self *Views) Branches() *ViewDriver
- func (self *Views) CommitDescription() *ViewDriver
- func (self *Views) CommitFiles() *ViewDriver
- func (self *Views) CommitMessage() *ViewDriver
- func (self *Views) Commits() *ViewDriver
- func (self *Views) Confirmation() *ViewDriver
- func (self *Views) Files() *ViewDriver
- func (self *Views) Information() *ViewDriver
- func (self *Views) Main() *ViewDriver
- func (self *Views) Menu() *ViewDriver
- func (self *Views) MergeConflicts() *ViewDriver
- func (self *Views) Options() *ViewDriver
- func (self *Views) PatchBuilding() *ViewDriver
- func (self *Views) PatchBuildingSecondary() *ViewDriver
- func (self *Views) ReflogCommits() *ViewDriver
- func (self *Views) RemoteBranches() *ViewDriver
- func (self *Views) Remotes() *ViewDriver
- func (self *Views) Search() *ViewDriver
- func (self *Views) Secondary() *ViewDriver
- func (self *Views) Staging() *ViewDriver
- func (self *Views) StagingSecondary() *ViewDriver
- func (self *Views) Stash() *ViewDriver
- func (self *Views) Status() *ViewDriver
- func (self *Views) SubCommits() *ViewDriver
- func (self *Views) Submodules() *ViewDriver
- func (self *Views) Suggestions() *ViewDriver
- func (self *Views) Tags() *ViewDriver
- func (self *Views) Tooltip() *ViewDriver
- func (self *Views) Worktrees() *ViewDriver
Constants ¶
const ( // These values will be passed to lazygit LAZYGIT_ROOT_DIR = "LAZYGIT_ROOT_DIR" SANDBOX_ENV_VAR = "SANDBOX" TEST_NAME_ENV_VAR = "TEST_NAME" WAIT_FOR_DEBUGGER_ENV_VAR = "WAIT_FOR_DEBUGGER" // These values will be passed to both lazygit and shell commands GIT_CONFIG_GLOBAL_ENV_VAR = "GIT_CONFIG_GLOBAL" // We pass PWD because if it's defined, Go will use it as the working directory // rather than make a syscall to the OS, and that means symlinks won't be resolved, // which is good to test for. PWD = "PWD" // We set $HOME and $GIT_CONFIG_NOGLOBAL during integrationt tests so // that older versions of git that don't respect $GIT_CONFIG_GLOBAL // will find the correct global config file for testing HOME = "HOME" GIT_CONFIG_NOGLOBAL = "GIT_CONFIG_NOGLOBAL" // These values will be passed through to lazygit and shell commands, with their // values inherited from the host environment PATH = "PATH" TERM = "TERM" )
const ClearKey = "<c-u>"
TODO: soft-code this
const IS_SELECTED_RULE_NAME = "is selected"
Variables ¶
var RandomBranchNames = []string{
"hotfix/fix-bug",
"r-u-fkn-srs",
"iserlohn-build",
"hotfix/fezzan-corridor",
"terra-investigation",
"quash-rebellion",
"feature/attack-on-odin",
"feature/peace-time",
"feature/repair-brunhild",
"feature/iserlohn-backdoor",
"bugfix/resolve-crash",
"enhancement/improve-performance",
"experimental/new-feature",
"release/v1.0.0",
"release/v2.0.0",
"chore/update-dependencies",
"docs/add-readme",
"refactor/cleanup-code",
"style/update-css",
"test/add-unit-tests",
}
var RandomCommitMessages = []string{
`Refactor HTTP client for better error handling`,
`Integrate pagination in user listings`,
`Fix incorrect type in updateUser function`,
`Create initial setup for postgres database`,
`Add unit tests for authentication service`,
`Improve efficiency of sorting algorithm in util package`,
`Resolve intermittent test failure in CartTest`,
`Introduce cache layer for product images`,
`Revamp User Interface of the settings page`,
`Remove deprecated uses of api endpoints`,
`Ensure proper escaping of SQL queries`,
`Implement feature flag for dark mode`,
`Add functionality for users to reset password`,
`Optimize performance of image loading on home screen`,
`Correct argument type in the sendEmail function`,
`Merge feature branch 'add-payment-gateway'`,
`Add validation to signup form fields`,
`Refactor User model to include middle name`,
`Update README with new setup instructions`,
`Extend session expiry time to 24 hours`,
`Implement rate limiting on login attempts`,
`Add sorting feature to product listing page`,
`Refactor logic in Lazygit Diff view`,
`Optimize Lazygit startup time`,
`Fix typos in documentation`,
`Move global variables to environment config`,
`Upgrade Rails version to 6.1.4`,
`Refactor user notifications system`,
`Implement user blocking functionality`,
`Improve Dockerfile for more efficient builds`,
`Introduce Redis for session management`,
`Ensure CSRF protection for all forms`,
`Implement bulk delete feature in admin panel`,
`Harden security of user password storage`,
`Resolve race condition in transaction handling`,
`Migrate legacy codebase to Typescript`,
`Update UX of password reset feature`,
`Add internationalization support for German`,
`Enhance logging in production environment`,
`Remove hardcoded values from payment module`,
`Introduce retry mechanism in network calls`,
`Handle edge case for zero quantity in cart`,
`Revamp error handling in user registration`,
`Replace deprecated lifecycle methods in React components`,
`Update styles according to new design guidelines`,
`Handle database connection failures gracefully`,
`Ensure atomicity of transactions in payment system`,
`Refactor session management using JWT`,
`Enhance user search with fuzzy matching`,
`Move constants to a separate config file`,
`Add TypeScript types to User module`,
`Implement automated backups for database`,
`Fix broken links on the help page`,
`Add end-to-end tests for checkout flow`,
`Add loading indicators to improve UX`,
`Improve accessibility of site navigation`,
`Refactor error messages for better clarity`,
`Enable gzip compression for faster page loads`,
`Set up CI/CD pipeline using GitHub actions`,
`Add a user-friendly 404 page`,
`Implement OAuth login with Google`,
`Resolve dependency conflicts in package.json`,
`Add proper alt text to all images for SEO`,
`Implement comment moderation feature`,
`Fix double encoding issue in URL parameters`,
`Resolve flickering issue in animation`,
`Update dependencies to latest stable versions`,
`Set proper cache headers for static assets`,
`Add structured data for better SEO`,
`Refactor to remove circular dependencies`,
`Add feature to report inappropriate content`,
`Implement mobile-friendly navigation menu`,
`Update privacy policy to comply with GDPR`,
`Fix memory leak issue in event listeners`,
`Improve form validation feedback for user`,
`Implement API versioning`,
`Improve resilience of system by adding circuit breaker`,
`Add sitemap.xml for better search engine indexing`,
`Set up performance monitoring with New Relic`,
`Introduce service worker for offline support`,
`Enhance email notifications with HTML templates`,
`Ensure all pages are responsive across devices`,
`Create helper functions to reduce code duplication`,
`Add 'remember me' feature to login`,
`Increase test coverage for User model`,
`Refactor error messages into a separate module`,
`Optimize images for faster loading`,
`Ensure correct HTTP status codes for all responses`,
`Implement auto-save feature in post editor`,
`Update user guide with new screenshots`,
`Implement load testing using Gatling`,
`Add keyboard shortcuts for commonly used actions`,
`Set up staging environment similar to production`,
`Ensure all forms use POST method for data submission`,
`Implement soft delete for user accounts`,
`Add Webpack for asset bundling`,
`Handle session timeout gracefully`,
`Remove unused code and libraries`,
`Integrate support for markdown in user posts`,
`Fix bug in timezone conversion.`,
}
var RandomFileContents = []string{
`package main
import (
"bytes"
"fmt"
"go/format"
"io/fs"
"os"
"strings"
"github.com/samber/lo"
)
func main() {
code := generateCode()
formattedCode, err := format.Source(code)
if err != nil {
panic(err)
}
if err := os.WriteFile("test_list.go", formattedCode, 0o644); err != nil {
panic(err)
}
}
`,
`
package tests
import (
"fmt"
"os"
"path/filepath"
"strings"
"github.com/jesseduffield/generics/set"
"github.com/jesseduffield/lazycore/pkg/utils"
"github.com/RetoranPetra/lazygit/pkg/integration/components"
"github.com/samber/lo"
)
func GetTests() []*components.IntegrationTest {
// first we ensure that each test in this directory has actually been added to the above list.
testCount := 0
testNamesSet := set.NewFromSlice(lo.Map(
tests,
func(test *components.IntegrationTest, _ int) string {
return test.Name()
},
))
}
`,
`
package components
import (
"os"
"strconv"
"strings"
"github.com/RetoranPetra/lazygit/pkg/commands/git_commands"
"github.com/RetoranPetra/lazygit/pkg/config"
integrationTypes "github.com/RetoranPetra/lazygit/pkg/integration/types"
"github.com/RetoranPetra/lazygit/pkg/utils"
"github.com/samber/lo"
)
// IntegrationTest describes an integration test that will be run against the lazygit gui.
// our unit tests will use this description to avoid a panic caused by attempting
// to get the test's name via it's file's path.
const unitTestDescription = "test test"
const (
defaultWidth = 100
defaultHeight = 100
)
`,
`package components
import (
"fmt"
"time"
"github.com/atotto/clipboard"
"github.com/RetoranPetra/lazygit/pkg/config"
integrationTypes "github.com/RetoranPetra/lazygit/pkg/integration/types"
)
type TestDriver struct {
gui integrationTypes.GuiDriver
keys config.KeybindingConfig
inputDelay int
*assertionHelper
shell *Shell
}
func NewTestDriver(gui integrationTypes.GuiDriver, shell *Shell, keys config.KeybindingConfig, inputDelay int) *TestDriver {
return &TestDriver{
gui: gui,
keys: keys,
inputDelay: inputDelay,
assertionHelper: &assertionHelper{gui: gui},
shell: shell,
}
}
// 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 (self *TestDriver) press(keyStr string) {
self.SetCaption(fmt.Sprintf("Pressing %s", keyStr))
self.gui.PressKey(keyStr)
self.Wait(self.inputDelay)
}
`,
`package updates
import (
"encoding/json"
"fmt"
"io"
"net/http"
"os"
"path/filepath"
"runtime"
"strings"
"time"
"github.com/go-errors/errors"
"github.com/kardianos/osext"
"github.com/RetoranPetra/lazygit/pkg/commands/oscommands"
"github.com/RetoranPetra/lazygit/pkg/common"
"github.com/RetoranPetra/lazygit/pkg/config"
"github.com/RetoranPetra/lazygit/pkg/constants"
"github.com/RetoranPetra/lazygit/pkg/utils"
)
// Updater checks for updates and does updates
type Updater struct {
*common.Common
Config config.AppConfigurer
OSCommand *oscommands.OSCommand
}
// Updaterer implements the check and update methods
type Updaterer interface {
CheckForNewUpdate()
Update()
}
`,
`
package utils
import (
"fmt"
"regexp"
"strings"
)
// IsValidEmail checks if an email address is valid
func IsValidEmail(email string) bool {
// Using a regex pattern to validate email addresses
// This is a simple example and might not cover all edge cases
emailPattern := ` + "`" + `^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$` + "`" + `
match, _ := regexp.MatchString(emailPattern, email)
return match
}
`,
`
package main
import (
"fmt"
"net/http"
"time"
"github.com/RetoranPetra/lazygit/pkg/utils"
)
func main() {
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Hello, the current time is: %s", time.Now().Format(time.RFC3339))
})
port := 8080
utils.PrintMessage(fmt.Sprintf("Server is listening on port %d", port))
http.ListenAndServe(fmt.Sprintf(":%d", port), nil)
}
`,
`
package logging
import (
"fmt"
"os"
"time"
)
// LogMessage represents a log message with its timestamp
type LogMessage struct {
Timestamp time.Time
Message string
}
// Log writes a message to the log file along with a timestamp
func Log(message string) {
logFile, err := os.OpenFile("app.log", os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
if err != nil {
fmt.Println("Error opening log file:", err)
return
}
defer logFile.Close()
logEntry := LogMessage{
Timestamp: time.Now(),
Message: message,
}
logLine := fmt.Sprintf("[%s] %s\n", logEntry.Timestamp.Format("2006-01-02 15:04:05"), logEntry.Message)
_, err = logFile.WriteString(logLine)
if err != nil {
fmt.Println("Error writing to log file:", err)
}
}
`,
`
package encryption
import (
"crypto/aes"
"crypto/cipher"
"crypto/rand"
"errors"
"io"
)
// Encrypt encrypts a plaintext using AES-GCM encryption
func Encrypt(key []byte, plaintext []byte) ([]byte, error) {
block, err := aes.NewCipher(key)
if err != nil {
return nil, err
}
aesGCM, err := cipher.NewGCM(block)
if err != nil {
return nil, err
}
nonce := make([]byte, aesGCM.NonceSize())
if _, err := io.ReadFull(rand.Reader, nonce); err != nil {
return nil, err
}
ciphertext := aesGCM.Seal(nil, nonce, plaintext, nil)
return append(nonce, ciphertext...), nil
}
`,
}
var RandomFiles = []RandomFile{
{Name: `http_client.go`, Content: `package httpclient`},
{Name: `user_listings.go`, Content: `package listings`},
{Name: `user_service.go`, Content: `package service`},
{Name: `database_setup.sql`, Content: `CREATE TABLE`},
{Name: `authentication_test.go`, Content: `package auth_test`},
{Name: `utils/sorting.go`, Content: `package utils`},
{Name: `tests/cart_test.go`, Content: `package tests`},
{Name: `cache/product_images.go`, Content: `package cache`},
{Name: `ui/settings_page.jsx`, Content: `import React`},
{Name: `api/deprecated_endpoints.go`, Content: `package api`},
{Name: `db/sql_queries.go`, Content: `package db`},
{Name: `features/dark_mode.go`, Content: `package features`},
{Name: `user/password_reset.go`, Content: `package user`},
{Name: `performance/image_loading.go`, Content: `package performance`},
{Name: `email/send_email.go`, Content: `package email`},
{Name: `merge/payment_gateway.go`, Content: `package merge`},
{Name: `forms/signup_validation.go`, Content: `package forms`},
{Name: `models/user.go`, Content: `package models`},
{Name: `README.md`, Content: `# Project`},
{Name: `config/session.go`, Content: `package config`},
{Name: `security/rate_limit.go`, Content: `package security`},
{Name: `product/sort_list.go`, Content: `package product`},
{Name: `lazygit/diff_view.go`, Content: `package lazygit`},
{Name: `performance/lazygit.go`, Content: `package performance`},
{Name: `docs/documentation.go`, Content: `package docs`},
{Name: `config/global_variables.go`, Content: `package config`},
{Name: `Gemfile`, Content: `source 'https://rubygems.org'`},
{Name: `notification/user_notification.go`, Content: `package notification`},
{Name: `user/blocking.go`, Content: `package user`},
{Name: `Dockerfile`, Content: `FROM ubuntu:18.04`},
{Name: `redis/session_manager.go`, Content: `package redis`},
{Name: `security/csrf_protection.go`, Content: `package security`},
{Name: `admin/bulk_delete.go`, Content: `package admin`},
{Name: `security/password_storage.go`, Content: `package security`},
{Name: `transactions/transaction_handling.go`, Content: `package transactions`},
{Name: `migrations/typescript_migration.go`, Content: `package migrations`},
{Name: `ui/password_reset.jsx`, Content: `import React`},
{Name: `i18n/german.go`, Content: `package i18n`},
{Name: `logging/production_logging.go`, Content: `package logging`},
{Name: `payment/hardcoded_values.go`, Content: `package payment`},
{Name: `network/retry.go`, Content: `package network`},
{Name: `cart/zero_quantity.go`, Content: `package cart`},
{Name: `registration/error_handling.go`, Content: `package registration`},
{Name: `components/deprecated_methods.jsx`, Content: `import React`},
{Name: `styles/new_guidelines.css`, Content: `.class {}`},
{Name: `db/connection_failure.go`, Content: `package db`},
{Name: `payment/transaction_atomicity.go`, Content: `package payment`},
{Name: `session/jwt_management.go`, Content: `package session`},
{Name: `search/fuzzy_matching.go`, Content: `package search`},
{Name: `config/constants.go`, Content: `package config`},
{Name: `models/user_types.go`, Content: `package models`},
{Name: `backup/database_backup.go`, Content: `package backup`},
{Name: `help_page/links.go`, Content: `package help_page`},
{Name: `tests/checkout_test.sql`, Content: `DELETE ALL TABLES;`},
{Name: `ui/loading_indicator.jsx`, Content: `import React`},
{Name: `navigation/site_navigation.go`, Content: `package navigation`},
{Name: `error/error_messages.go`, Content: `package error`},
{Name: `performance/gzip_compression.go`, Content: `package performance`},
{Name: `.github/workflows/ci.yml`, Content: `name: CI`},
{Name: `pages/404.html`, Content: `<html></html>`},
{Name: `oauth/google_login.go`, Content: `package oauth`},
{Name: `package.json`, Content: `{}`},
{Name: `seo/alt_text.go`, Content: `package seo`},
{Name: `moderation/comment_moderation.go`, Content: `package moderation`},
{Name: `url/double_encoding.go`, Content: `package url`},
{Name: `animation/flickering.go`, Content: `package animation`},
{Name: `upgrade_dependencies.sh`, Content: `#!/bin/sh`},
{Name: `security/csrf_protection2.go`, Content: `package security`},
{Name: `admin/bulk_delete2.go`, Content: `package admin`},
{Name: `security/password_storage2.go`, Content: `package security`},
{Name: `transactions/transaction_handling2.go`, Content: `package transactions`},
{Name: `migrations/typescript_migration2.go`, Content: `package migrations`},
{Name: `ui/password_reset2.jsx`, Content: `import React`},
{Name: `i18n/german2.go`, Content: `package i18n`},
{Name: `logging/production_logging2.go`, Content: `package logging`},
{Name: `payment/hardcoded_values2.go`, Content: `package payment`},
{Name: `network/retry2.go`, Content: `package network`},
{Name: `cart/zero_quantity2.go`, Content: `package cart`},
{Name: `registration/error_handling2.go`, Content: `package registration`},
{Name: `components/deprecated_methods2.jsx`, Content: `import React`},
{Name: `styles/new_guidelines2.css`, Content: `.class {}`},
{Name: `db/connection_failure2.go`, Content: `package db`},
{Name: `payment/transaction_atomicity2.go`, Content: `package payment`},
{Name: `session/jwt_management2.go`, Content: `package session`},
{Name: `search/fuzzy_matching2.go`, Content: `package search`},
{Name: `config/constants2.go`, Content: `package config`},
{Name: `models/user_types2.go`, Content: `package models`},
{Name: `backup/database_backup2.go`, Content: `package backup`},
{Name: `help_page/links2.go`, Content: `package help_page`},
{Name: `tests/checkout_test2.go`, Content: `package tests`},
{Name: `ui/loading_indicator2.jsx`, Content: `import React`},
{Name: `navigation/site_navigation2.go`, Content: `package navigation`},
{Name: `error/error_messages2.go`, Content: `package error`},
{Name: `performance/gzip_compression2.go`, Content: `package performance`},
{Name: `.github/workflows/ci2.yml`, Content: `name: CI`},
{Name: `pages/4042.html`, Content: `<html></html>`},
{Name: `oauth/google_login2.go`, Content: `package oauth`},
{Name: `package2.json`, Content: `{}`},
{Name: `seo/alt_text2.go`, Content: `package seo`},
{Name: `moderation/comment_moderation2.go`, Content: `package moderation`},
}
Functions ¶
func InputDelay ¶
func InputDelay() int
this is the delay in milliseconds between keypresses or mouse clicks defaults to zero
func NewTestEnvironment ¶
func RunTests ¶
func RunTests(args RunTestArgs) error
This function lets you run tests either from within `go test` or from a regular binary. The reason for having two separate ways of testing is that `go test` isn't great at showing what's actually happening during the test, but it's still good at running tests in telling you about their results.
func TestNameFromFilePath ¶
Types ¶
type AlertDriver ¶
type AlertDriver struct {
// contains filtered or unexported fields
}
func (*AlertDriver) Cancel ¶
func (self *AlertDriver) Cancel()
func (*AlertDriver) Confirm ¶
func (self *AlertDriver) Confirm()
func (*AlertDriver) Content ¶
func (self *AlertDriver) Content(expected *TextMatcher) *AlertDriver
asserts that the alert view has the expected content
func (*AlertDriver) Title ¶
func (self *AlertDriver) Title(expected *TextMatcher) *AlertDriver
asserts that the alert view has the expected title
type CommitDescriptionPanelDriver ¶
type CommitDescriptionPanelDriver struct {
// contains filtered or unexported fields
}
func (*CommitDescriptionPanelDriver) AddCoAuthor ¶
func (self *CommitDescriptionPanelDriver) AddCoAuthor(author string) *CommitDescriptionPanelDriver
func (*CommitDescriptionPanelDriver) AddNewline ¶
func (self *CommitDescriptionPanelDriver) AddNewline() *CommitDescriptionPanelDriver
func (*CommitDescriptionPanelDriver) Cancel ¶
func (self *CommitDescriptionPanelDriver) Cancel()
func (*CommitDescriptionPanelDriver) Content ¶
func (self *CommitDescriptionPanelDriver) Content(expected *TextMatcher) *CommitDescriptionPanelDriver
asserts on the current context of the description
func (*CommitDescriptionPanelDriver) GoToBeginning ¶
func (self *CommitDescriptionPanelDriver) GoToBeginning() *CommitDescriptionPanelDriver
func (*CommitDescriptionPanelDriver) SwitchToSummary ¶
func (self *CommitDescriptionPanelDriver) SwitchToSummary() *CommitMessagePanelDriver
func (*CommitDescriptionPanelDriver) Title ¶
func (self *CommitDescriptionPanelDriver) Title(expected *TextMatcher) *CommitDescriptionPanelDriver
func (*CommitDescriptionPanelDriver) Type ¶
func (self *CommitDescriptionPanelDriver) Type(value string) *CommitDescriptionPanelDriver
type CommitMessagePanelDriver ¶
type CommitMessagePanelDriver struct {
// contains filtered or unexported fields
}
func (*CommitMessagePanelDriver) Cancel ¶
func (self *CommitMessagePanelDriver) Cancel()
func (*CommitMessagePanelDriver) Clear ¶
func (self *CommitMessagePanelDriver) Clear() *CommitMessagePanelDriver
func (*CommitMessagePanelDriver) Close ¶
func (self *CommitMessagePanelDriver) Close()
func (*CommitMessagePanelDriver) Confirm ¶
func (self *CommitMessagePanelDriver) Confirm()
func (*CommitMessagePanelDriver) Content ¶
func (self *CommitMessagePanelDriver) Content(expected *TextMatcher) *CommitMessagePanelDriver
asserts on the current context in the prompt
func (*CommitMessagePanelDriver) InitialText ¶
func (self *CommitMessagePanelDriver) InitialText(expected *TextMatcher) *CommitMessagePanelDriver
asserts on the text initially present in the prompt
func (*CommitMessagePanelDriver) OpenCommitMenu ¶
func (self *CommitMessagePanelDriver) OpenCommitMenu() *CommitMessagePanelDriver
func (*CommitMessagePanelDriver) SelectNextMessage ¶
func (self *CommitMessagePanelDriver) SelectNextMessage() *CommitMessagePanelDriver
func (*CommitMessagePanelDriver) SelectPreviousMessage ¶
func (self *CommitMessagePanelDriver) SelectPreviousMessage() *CommitMessagePanelDriver
func (*CommitMessagePanelDriver) SwitchToDescription ¶
func (self *CommitMessagePanelDriver) SwitchToDescription() *CommitDescriptionPanelDriver
func (*CommitMessagePanelDriver) SwitchToEditor ¶
func (self *CommitMessagePanelDriver) SwitchToEditor()
func (*CommitMessagePanelDriver) Title ¶
func (self *CommitMessagePanelDriver) Title(expected *TextMatcher) *CommitMessagePanelDriver
asserts that the confirmation view has the expected title
func (*CommitMessagePanelDriver) Type ¶
func (self *CommitMessagePanelDriver) Type(value string) *CommitMessagePanelDriver
type Common ¶
type Common struct {
// contains filtered or unexported fields
}
for running common actions
func (*Common) AbortMerge ¶
func (self *Common) AbortMerge()
func (*Common) AbortRebase ¶
func (self *Common) AbortRebase()
func (*Common) AcknowledgeConflicts ¶
func (self *Common) AcknowledgeConflicts()
func (*Common) ConfirmDiscardLines ¶
func (self *Common) ConfirmDiscardLines()
func (*Common) ContinueMerge ¶
func (self *Common) ContinueMerge()
func (*Common) ContinueOnConflictsResolved ¶
func (self *Common) ContinueOnConflictsResolved()
func (*Common) ContinueRebase ¶
func (self *Common) ContinueRebase()
func (*Common) ResetBisect ¶
func (self *Common) ResetBisect()
func (*Common) ResetCustomPatch ¶
func (self *Common) ResetCustomPatch()
func (*Common) SelectPatchOption ¶
func (self *Common) SelectPatchOption(matcher *TextMatcher)
type ConfirmationDriver ¶
type ConfirmationDriver struct {
// contains filtered or unexported fields
}
func (*ConfirmationDriver) Cancel ¶
func (self *ConfirmationDriver) Cancel()
func (*ConfirmationDriver) Confirm ¶
func (self *ConfirmationDriver) Confirm()
func (*ConfirmationDriver) Content ¶
func (self *ConfirmationDriver) Content(expected *TextMatcher) *ConfirmationDriver
asserts that the confirmation view has the expected content
func (*ConfirmationDriver) Title ¶
func (self *ConfirmationDriver) Title(expected *TextMatcher) *ConfirmationDriver
asserts that the confirmation view has the expected title
func (*ConfirmationDriver) Wait ¶
func (self *ConfirmationDriver) Wait(milliseconds int) *ConfirmationDriver
type FileSystem ¶
type FileSystem struct {
// contains filtered or unexported fields
}
func (*FileSystem) FileContent ¶
func (self *FileSystem) FileContent(path string, matcher *TextMatcher)
Asserts that the file at the given path has the given content
func (*FileSystem) PathNotPresent ¶
func (self *FileSystem) PathNotPresent(path string)
This does _not_ check the files panel, it actually checks the filesystem
func (*FileSystem) PathPresent ¶
func (self *FileSystem) PathPresent(path string)
This does _not_ check the files panel, it actually checks the filesystem
type Git ¶
type Git struct {
// contains filtered or unexported fields
}
func (*Git) CurrentBranchName ¶
func (*Git) Version ¶
func (self *Git) Version() *git_commands.GitVersion
type GitVersionRestriction ¶
type GitVersionRestriction struct {
// contains filtered or unexported fields
}
func AtLeast ¶
func AtLeast(version string) GitVersionRestriction
Verifies the version is at least the given version (inclusive)
func Before ¶
func Before(version string) GitVersionRestriction
Verifies the version is before the given version (exclusive)
func Includes ¶
func Includes(versions ...string) GitVersionRestriction
type IntMatcher ¶
func AnyInt ¶
func AnyInt() *IntMatcher
func EqualsInt ¶
func EqualsInt(target int) *IntMatcher
func GreaterThan ¶
func GreaterThan(target int) *IntMatcher
func LessThan ¶
func LessThan(target int) *IntMatcher
func (*IntMatcher) EqualsInt ¶
func (self *IntMatcher) EqualsInt(target int) *IntMatcher
func (*IntMatcher) GreaterThan ¶
func (self *IntMatcher) GreaterThan(target int) *IntMatcher
func (*IntMatcher) LessThan ¶
func (self *IntMatcher) LessThan(target int) *IntMatcher
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) ExtraEnvVars ¶
func (self *IntegrationTest) ExtraEnvVars() map[string]string
func (*IntegrationTest) HeadlessDimensions ¶
func (self *IntegrationTest) HeadlessDimensions() (int, int)
func (*IntegrationTest) IsDemo ¶
func (self *IntegrationTest) IsDemo() bool
func (*IntegrationTest) Name ¶
func (self *IntegrationTest) Name() string
func (*IntegrationTest) RequiresHeadless ¶
func (self *IntegrationTest) RequiresHeadless() bool
func (*IntegrationTest) Run ¶
func (self *IntegrationTest) Run(gui integrationTypes.GuiDriver)
func (*IntegrationTest) SetupConfig ¶
func (self *IntegrationTest) SetupConfig(config *config.AppConfig)
func (*IntegrationTest) SetupRepo ¶
func (self *IntegrationTest) SetupRepo(shell *Shell)
func (*IntegrationTest) ShouldRunForGitVersion ¶
func (self *IntegrationTest) ShouldRunForGitVersion(version *git_commands.GitVersion) bool
func (*IntegrationTest) Skip ¶
func (self *IntegrationTest) Skip() bool
type Matcher ¶
type Matcher[T any] struct { // contains filtered or unexported fields }
for making assertions on string values
type MenuDriver ¶
type MenuDriver struct {
// contains filtered or unexported fields
}
func (*MenuDriver) Cancel ¶
func (self *MenuDriver) Cancel()
func (*MenuDriver) Confirm ¶
func (self *MenuDriver) Confirm() *MenuDriver
func (*MenuDriver) Filter ¶
func (self *MenuDriver) Filter(text string) *MenuDriver
func (*MenuDriver) LineCount ¶
func (self *MenuDriver) LineCount(matcher *IntMatcher) *MenuDriver
func (*MenuDriver) Lines ¶
func (self *MenuDriver) Lines(matchers ...*TextMatcher) *MenuDriver
func (*MenuDriver) Select ¶
func (self *MenuDriver) Select(option *TextMatcher) *MenuDriver
func (*MenuDriver) Tap ¶
func (self *MenuDriver) Tap(f func()) *MenuDriver
func (*MenuDriver) Title ¶
func (self *MenuDriver) Title(expected *TextMatcher) *MenuDriver
asserts that the popup has the expected title
func (*MenuDriver) Tooltip ¶
func (self *MenuDriver) Tooltip(option *TextMatcher) *MenuDriver
func (*MenuDriver) TopLines ¶
func (self *MenuDriver) TopLines(matchers ...*TextMatcher) *MenuDriver
func (*MenuDriver) Wait ¶
func (self *MenuDriver) Wait(milliseconds int) *MenuDriver
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 ExtraEnvVars map[string]string // for when a test is flakey Skip bool // to run a test only on certain git versions GitVersion GitVersionRestriction // width and height when running in headless mode, for testing // the UI in different sizes. // If these are set, the test must be run in headless mode Width int Height int // If true, this is not a test but a demo to be added to our docs IsDemo 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/_results.
func (Paths) Actual ¶
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 ¶
this is the 'repo' directory within the 'actual' directory, where a lazygit test will start within.
type Popup ¶
type Popup struct {
// contains filtered or unexported fields
}
func (*Popup) Alert ¶
func (self *Popup) Alert() *AlertDriver
func (*Popup) CommitDescriptionPanel ¶
func (self *Popup) CommitDescriptionPanel() *CommitMessagePanelDriver
func (*Popup) CommitMessagePanel ¶
func (self *Popup) CommitMessagePanel() *CommitMessagePanelDriver
func (*Popup) Confirmation ¶
func (self *Popup) Confirmation() *ConfirmationDriver
func (*Popup) Menu ¶
func (self *Popup) Menu() *MenuDriver
func (*Popup) Prompt ¶
func (self *Popup) Prompt() *PromptDriver
type PromptDriver ¶
type PromptDriver struct {
// contains filtered or unexported fields
}
func (*PromptDriver) Cancel ¶
func (self *PromptDriver) Cancel()
func (*PromptDriver) Clear ¶
func (self *PromptDriver) Clear() *PromptDriver
func (*PromptDriver) Confirm ¶
func (self *PromptDriver) Confirm()
func (*PromptDriver) ConfirmFirstSuggestion ¶
func (self *PromptDriver) ConfirmFirstSuggestion()
func (*PromptDriver) ConfirmSuggestion ¶
func (self *PromptDriver) ConfirmSuggestion(matcher *TextMatcher)
func (*PromptDriver) InitialText ¶
func (self *PromptDriver) InitialText(expected *TextMatcher) *PromptDriver
asserts on the text initially present in the prompt
func (*PromptDriver) SuggestionLines ¶
func (self *PromptDriver) SuggestionLines(matchers ...*TextMatcher) *PromptDriver
func (*PromptDriver) SuggestionTopLines ¶
func (self *PromptDriver) SuggestionTopLines(matchers ...*TextMatcher) *PromptDriver
func (*PromptDriver) Title ¶
func (self *PromptDriver) Title(expected *TextMatcher) *PromptDriver
asserts that the popup has the expected title
func (*PromptDriver) Type ¶
func (self *PromptDriver) Type(value string) *PromptDriver
type RandomFile ¶
type RunTestArgs ¶
type RunTestArgs struct { Tests []*IntegrationTest Logf func(format string, formatArgs ...interface{}) RunCmd func(cmd *exec.Cmd) (int, error) TestWrapper func(test *IntegrationTest, f func() error) Sandbox bool WaitForDebugger bool RaceDetector bool CodeCoverageDir string InputDelay int MaxAttempts int }
type SearchDriver ¶
type SearchDriver struct {
// contains filtered or unexported fields
}
func (*SearchDriver) Cancel ¶
func (self *SearchDriver) Cancel()
func (*SearchDriver) Clear ¶
func (self *SearchDriver) Clear() *SearchDriver
func (*SearchDriver) Confirm ¶
func (self *SearchDriver) Confirm()
func (*SearchDriver) InitialText ¶
func (self *SearchDriver) InitialText(expected *TextMatcher) *SearchDriver
asserts on the text initially present in the prompt
func (*SearchDriver) Type ¶
func (self *SearchDriver) Type(value string) *SearchDriver
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 (*Shell) AddFileInWorktree ¶
func (*Shell) AddWorktree ¶
func (*Shell) AddWorktreeCheckout ¶
add worktree and have it checkout the base branch
func (*Shell) Chdir ¶
The final value passed to Chdir() during setup will be the directory the test is run from.
func (*Shell) CloneIntoRemote ¶
func (*Shell) CloneIntoSubmodule ¶
func (*Shell) ContinueMerge ¶
func (*Shell) CopyHelpFile ¶
Help files are located at test/files from the root the lazygit repo. E.g. You may want to create a pre-commit hook file there, then call this function to copy it into your test repo.
func (*Shell) CreateAnnotatedTag ¶
func (*Shell) CreateFileAndAdd ¶
convenience method for creating a file and adding it
func (*Shell) CreateLightweightTag ¶
func (*Shell) CreateNCommits ¶
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) CreateNCommitsStartingAt ¶
func (*Shell) CreateNCommitsWithRandomMessages ¶
Only to be used in demos, because the list might change and we don't want tests to break when it does.
func (*Shell) CreateRepoHistory ¶
This creates a repo history of commits It uses a branching strategy where each feature branch is directly branched off of the master branch Only to be used in demos
func (*Shell) DeleteFile ¶
func (*Shell) DeleteFileAndAdd ¶
convenience method for deleting a file and adding it
func (*Shell) EmptyCommit ¶
func (*Shell) EmptyCommitDaysAgo ¶
func (*Shell) EmptyCommitWithDate ¶
func (*Shell) MakeExecutable ¶
func (*Shell) PushBranch ¶
func (*Shell) RandomChangeCommit ¶
Creates a commit with a random file Only to be used in demos
func (*Shell) RemoveRemoteBranch ¶
func (*Shell) RunCommand ¶
func (*Shell) RunCommandExpectError ¶
func (*Shell) RunCommandWithEnv ¶
Run a command with additional environment variables set
func (*Shell) RunShellCommand ¶
func (*Shell) SetBranchUpstream ¶
type TestDriver ¶
type TestDriver struct {
// contains filtered or unexported fields
}
func NewTestDriver ¶
func NewTestDriver(gui integrationTypes.GuiDriver, shell *Shell, keys config.KeybindingConfig, inputDelay int) *TestDriver
func (*TestDriver) Common ¶
func (self *TestDriver) Common() *Common
func (*TestDriver) ExpectClipboard ¶
func (self *TestDriver) ExpectClipboard(matcher *TextMatcher)
func (*TestDriver) ExpectPopup ¶
func (self *TestDriver) ExpectPopup() *Popup
for interacting with popups
func (*TestDriver) ExpectSearch ¶
func (self *TestDriver) ExpectSearch() *SearchDriver
func (*TestDriver) ExpectToast ¶
func (self *TestDriver) ExpectToast(matcher *TextMatcher) *TestDriver
func (*TestDriver) Fail ¶
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 ¶
func (self *TestDriver) FileSystem() *FileSystem
for making assertions on the file system
func (*TestDriver) Git ¶
func (self *TestDriver) Git() *Git
for making assertions through git itself
func (*TestDriver) GlobalPress ¶
func (self *TestDriver) GlobalPress(keyStr string)
Should only be used in specific cases where you're doing something weird! E.g. invoking a global keybinding from within a popup. You probably shouldn't use this function, and should instead go through a view like t.Views().Commit().Focus().Press(...)
func (*TestDriver) Log ¶
func (self *TestDriver) Log(message string)
func (*TestDriver) LogUI ¶
func (self *TestDriver) LogUI(message string)
func (*TestDriver) SetCaption ¶
func (self *TestDriver) SetCaption(caption string)
func (*TestDriver) SetCaptionPrefix ¶
func (self *TestDriver) SetCaptionPrefix(prefix string)
func (*TestDriver) Shell ¶
func (self *TestDriver) Shell() *Shell
allows the user to run shell commands during the test to emulate background activity
func (*TestDriver) Views ¶
func (self *TestDriver) Views() *Views
for making assertions on lazygit views
func (*TestDriver) Wait ¶
func (self *TestDriver) Wait(milliseconds int)
for when you want to allow lazygit to process something before continuing
type TextMatcher ¶
type TextMatcher struct { // If you add or change a field here, be sure to update the copy // code in checkIsSelected() *Matcher[string] }
func AnyString ¶
func AnyString() *TextMatcher
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) *TextMatcher
func DoesNotContain ¶
func DoesNotContain(target string) *TextMatcher
func DoesNotContainAnyOf ¶
func DoesNotContainAnyOf(targets ...string) *TextMatcher
func Equals ¶
func Equals(target string) *TextMatcher
func MatchesRegexp ¶
func MatchesRegexp(target string) *TextMatcher
func (*TextMatcher) Contains ¶
func (self *TextMatcher) Contains(target string) *TextMatcher
func (*TextMatcher) DoesNotContain ¶
func (self *TextMatcher) DoesNotContain(target string) *TextMatcher
func (*TextMatcher) DoesNotContainAnyOf ¶
func (self *TextMatcher) DoesNotContainAnyOf(targets []string) *TextMatcher
func (*TextMatcher) Equals ¶
func (self *TextMatcher) Equals(target string) *TextMatcher
func (*TextMatcher) IsSelected ¶
func (self *TextMatcher) IsSelected() *TextMatcher
special rule that is only to be used in the TopLines and Lines methods, as a way of asserting that a given line is selected.
func (*TextMatcher) MatchesRegexp ¶
func (self *TextMatcher) MatchesRegexp(target string) *TextMatcher
type ViewDriver ¶
type ViewDriver struct {
// contains filtered or unexported fields
}
func (*ViewDriver) Click ¶
func (self *ViewDriver) Click(x, y int) *ViewDriver
func (*ViewDriver) ContainsColoredText ¶
func (self *ViewDriver) ContainsColoredText(fgColorStr string, text string) *ViewDriver
func (*ViewDriver) ContainsLines ¶
func (self *ViewDriver) ContainsLines(matchers ...*TextMatcher) *ViewDriver
asserts that somewhere in the view there are consequetive lines matching the given matchers.
func (*ViewDriver) Content ¶
func (self *ViewDriver) Content(matcher *TextMatcher) *ViewDriver
asserts on the content of the view i.e. the stuff within the view's frame.
func (*ViewDriver) DoesNotContainColoredText ¶
func (self *ViewDriver) DoesNotContainColoredText(fgColorStr string, text string) *ViewDriver
func (*ViewDriver) FilterOrSearch ¶
func (self *ViewDriver) FilterOrSearch(text string) *ViewDriver
will filter or search depending on whether the view supports filtering/searching
func (*ViewDriver) Focus ¶
func (self *ViewDriver) Focus() *ViewDriver
focus the view (assumes the view is a side-view)
func (*ViewDriver) IsEmpty ¶
func (self *ViewDriver) IsEmpty() *ViewDriver
returns true if the view is a list view and it contains no items
func (*ViewDriver) IsFocused ¶
func (self *ViewDriver) IsFocused() *ViewDriver
asserts that the view is focused
func (*ViewDriver) IsInvisible ¶
func (self *ViewDriver) IsInvisible() *ViewDriver
func (*ViewDriver) IsVisible ¶
func (self *ViewDriver) IsVisible() *ViewDriver
func (*ViewDriver) LineCount ¶
func (self *ViewDriver) LineCount(matcher *IntMatcher) *ViewDriver
func (*ViewDriver) Lines ¶
func (self *ViewDriver) Lines(matchers ...*TextMatcher) *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. If you only care about a subset of lines, use the ContainsLines method instead.
func (*ViewDriver) NavigateToLine ¶
func (self *ViewDriver) NavigateToLine(matcher *TextMatcher) *ViewDriver
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 BufferLines 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 (*ViewDriver) Press ¶
func (self *ViewDriver) Press(keyStr string) *ViewDriver
func (*ViewDriver) PressEnter ¶
func (self *ViewDriver) PressEnter() *ViewDriver
i.e. pressing space
func (*ViewDriver) PressEscape ¶
func (self *ViewDriver) PressEscape() *ViewDriver
i.e. pressing escape
func (*ViewDriver) PressFast ¶
func (self *ViewDriver) PressFast(keyStr string) *ViewDriver
for use when typing or navigating, because in demos we want that to happen faster
func (*ViewDriver) PressPrimaryAction ¶
func (self *ViewDriver) PressPrimaryAction() *ViewDriver
i.e. pressing space
func (*ViewDriver) SelectNextItem ¶
func (self *ViewDriver) SelectNextItem() *ViewDriver
i.e. pressing down arrow
func (*ViewDriver) SelectPreviousItem ¶
func (self *ViewDriver) SelectPreviousItem() *ViewDriver
i.e. pressing up arrow
func (*ViewDriver) SelectedLine ¶
func (self *ViewDriver) SelectedLine(matcher *TextMatcher) *ViewDriver
asserts on the selected line of the view. If you are selecting a range, you should use the SelectedLines method instead.
func (*ViewDriver) SelectedLineIdx ¶
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) SelectedLines ¶
func (self *ViewDriver) SelectedLines(matchers ...*TextMatcher) *ViewDriver
asserts on the lines that are selected in the view. Don't use the `IsSelected` matcher with this because it's redundant.
func (*ViewDriver) Self ¶
func (self *ViewDriver) Self() *ViewDriver
This purely exists as a convenience method for those who hate the trailing periods in multi-line method chains
func (*ViewDriver) SetCaption ¶
func (self *ViewDriver) SetCaption(caption string) *ViewDriver
func (*ViewDriver) SetCaptionPrefix ¶
func (self *ViewDriver) SetCaptionPrefix(prefix string) *ViewDriver
func (*ViewDriver) Tap ¶
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 ¶
func (self *ViewDriver) Title(expected *TextMatcher) *ViewDriver
asserts that the view has the expected title
func (*ViewDriver) TopLines ¶
func (self *ViewDriver) TopLines(matchers ...*TextMatcher) *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.
func (*ViewDriver) VisibleLines ¶
func (self *ViewDriver) VisibleLines(matchers ...*TextMatcher) *ViewDriver
Asserts on the visible lines of the view. Note, this assumes that the view's viewport is filled with lines
func (*ViewDriver) Wait ¶
func (self *ViewDriver) Wait(milliseconds int) *ViewDriver
type Views ¶
type Views struct {
// contains filtered or unexported fields
}
func (*Views) AppStatus ¶
func (self *Views) AppStatus() *ViewDriver
func (*Views) Branches ¶
func (self *Views) Branches() *ViewDriver
func (*Views) CommitDescription ¶
func (self *Views) CommitDescription() *ViewDriver
func (*Views) CommitFiles ¶
func (self *Views) CommitFiles() *ViewDriver
func (*Views) CommitMessage ¶
func (self *Views) CommitMessage() *ViewDriver
func (*Views) Commits ¶
func (self *Views) Commits() *ViewDriver
func (*Views) Confirmation ¶
func (self *Views) Confirmation() *ViewDriver
func (*Views) Files ¶
func (self *Views) Files() *ViewDriver
func (*Views) Information ¶
func (self *Views) Information() *ViewDriver
func (*Views) Main ¶
func (self *Views) Main() *ViewDriver
func (*Views) Menu ¶
func (self *Views) Menu() *ViewDriver
func (*Views) MergeConflicts ¶
func (self *Views) MergeConflicts() *ViewDriver
func (*Views) Options ¶
func (self *Views) Options() *ViewDriver
func (*Views) PatchBuilding ¶
func (self *Views) PatchBuilding() *ViewDriver
func (*Views) PatchBuildingSecondary ¶
func (self *Views) PatchBuildingSecondary() *ViewDriver
func (*Views) ReflogCommits ¶
func (self *Views) ReflogCommits() *ViewDriver
func (*Views) RemoteBranches ¶
func (self *Views) RemoteBranches() *ViewDriver
func (*Views) Remotes ¶
func (self *Views) Remotes() *ViewDriver
func (*Views) Search ¶
func (self *Views) Search() *ViewDriver
func (*Views) Secondary ¶
func (self *Views) Secondary() *ViewDriver
func (*Views) Staging ¶
func (self *Views) Staging() *ViewDriver
func (*Views) StagingSecondary ¶
func (self *Views) StagingSecondary() *ViewDriver
func (*Views) Stash ¶
func (self *Views) Stash() *ViewDriver
func (*Views) Status ¶
func (self *Views) Status() *ViewDriver
func (*Views) SubCommits ¶
func (self *Views) SubCommits() *ViewDriver
func (*Views) Submodules ¶
func (self *Views) Submodules() *ViewDriver
func (*Views) Suggestions ¶
func (self *Views) Suggestions() *ViewDriver
func (*Views) Tags ¶
func (self *Views) Tags() *ViewDriver
func (*Views) Tooltip ¶
func (self *Views) Tooltip() *ViewDriver
func (*Views) Worktrees ¶
func (self *Views) Worktrees() *ViewDriver
Source Files ¶
- alert_driver.go
- assertion_helper.go
- commit_description_panel_driver.go
- commit_message_panel_driver.go
- common.go
- confirmation_driver.go
- env.go
- file_system.go
- git.go
- int_matcher.go
- matcher.go
- menu_driver.go
- paths.go
- popup.go
- prompt_driver.go
- random.go
- runner.go
- search_driver.go
- shell.go
- test.go
- test_driver.go
- text_matcher.go
- view_driver.go
- views.go