mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-06-15 00:15:32 +02:00
Add demo test variant
We're piggybacking on our existing integration test framework to record demos that we can include in our docs
This commit is contained in:
@ -74,6 +74,13 @@ func (self *Shell) RunShellCommand(cmdStr string) *Shell {
|
||||
|
||||
func (self *Shell) CreateFile(path string, content string) *Shell {
|
||||
fullPath := filepath.Join(self.dir, path)
|
||||
|
||||
// create any required directories
|
||||
dir := filepath.Dir(fullPath)
|
||||
if err := os.MkdirAll(dir, 0o755); err != nil {
|
||||
self.fail(fmt.Sprintf("error creating directory: %s\n%s", dir, err))
|
||||
}
|
||||
|
||||
err := os.WriteFile(fullPath, []byte(content), 0o644)
|
||||
if err != nil {
|
||||
self.fail(fmt.Sprintf("error creating file: %s\n%s", fullPath, err))
|
||||
@ -195,6 +202,21 @@ func (self *Shell) CreateNCommitsStartingAt(n, startIndex int) *Shell {
|
||||
return self
|
||||
}
|
||||
|
||||
// Only to be used in demos, because the list might change and we don't want
|
||||
// tests to break when it does.
|
||||
func (self *Shell) CreateNCommitsWithRandomMessages(n int) *Shell {
|
||||
for i := 0; i < n; i++ {
|
||||
file := RandomFiles[i]
|
||||
self.CreateFileAndAdd(
|
||||
file.Name,
|
||||
file.Content,
|
||||
).
|
||||
Commit(RandomCommitMessages[i])
|
||||
}
|
||||
|
||||
return self
|
||||
}
|
||||
|
||||
func (self *Shell) SetConfig(key string, value string) *Shell {
|
||||
self.RunCommand([]string{"git", "config", "--local", key, value})
|
||||
return self
|
||||
|
Reference in New Issue
Block a user