mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-27 23:08:02 +02:00
Add test for checking out a file from a commit
This works, we just didn't have a test for it.
This commit is contained in:
parent
5038fa2d51
commit
ac7d8ad025
55
pkg/integration/tests/commit/checkout_file_from_commit.go
Normal file
55
pkg/integration/tests/commit/checkout_file_from_commit.go
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
package commit
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/jesseduffield/lazygit/pkg/config"
|
||||||
|
. "github.com/jesseduffield/lazygit/pkg/integration/components"
|
||||||
|
)
|
||||||
|
|
||||||
|
var CheckoutFileFromCommit = NewIntegrationTest(NewIntegrationTestArgs{
|
||||||
|
Description: "Checkout a file from a commit",
|
||||||
|
ExtraCmdArgs: []string{},
|
||||||
|
Skip: false,
|
||||||
|
SetupConfig: func(config *config.AppConfig) {},
|
||||||
|
SetupRepo: func(shell *Shell) {
|
||||||
|
shell.CreateFileAndAdd("file.txt", "one\n")
|
||||||
|
shell.Commit("one")
|
||||||
|
shell.CreateFileAndAdd("file.txt", "two\n")
|
||||||
|
shell.Commit("two")
|
||||||
|
shell.CreateFileAndAdd("file.txt", "three\n")
|
||||||
|
shell.Commit("three")
|
||||||
|
shell.CreateFileAndAdd("file.txt", "four\n")
|
||||||
|
shell.Commit("four")
|
||||||
|
},
|
||||||
|
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
||||||
|
t.Views().Commits().
|
||||||
|
Focus().
|
||||||
|
Lines(
|
||||||
|
Contains("four").IsSelected(),
|
||||||
|
Contains("three"),
|
||||||
|
Contains("two"),
|
||||||
|
Contains("one"),
|
||||||
|
).
|
||||||
|
NavigateToLine(Contains("three")).
|
||||||
|
Tap(func() {
|
||||||
|
t.Views().Main().ContainsLines(
|
||||||
|
Contains("-two"),
|
||||||
|
Contains("+three"),
|
||||||
|
)
|
||||||
|
}).
|
||||||
|
PressEnter()
|
||||||
|
|
||||||
|
t.Views().CommitFiles().
|
||||||
|
IsFocused().
|
||||||
|
Lines(
|
||||||
|
Equals("M file.txt"),
|
||||||
|
).
|
||||||
|
Press(keys.CommitFiles.CheckoutCommitFile)
|
||||||
|
|
||||||
|
t.Views().Files().
|
||||||
|
Lines(
|
||||||
|
Equals("M file.txt"),
|
||||||
|
)
|
||||||
|
|
||||||
|
t.FileSystem().FileContent("file.txt", Equals("three\n"))
|
||||||
|
},
|
||||||
|
})
|
@ -89,6 +89,7 @@ var tests = []*components.IntegrationTest{
|
|||||||
commit.AmendWhenThereAreConflictsAndContinue,
|
commit.AmendWhenThereAreConflictsAndContinue,
|
||||||
commit.AutoWrapMessage,
|
commit.AutoWrapMessage,
|
||||||
commit.Checkout,
|
commit.Checkout,
|
||||||
|
commit.CheckoutFileFromCommit,
|
||||||
commit.Commit,
|
commit.Commit,
|
||||||
commit.CommitMultiline,
|
commit.CommitMultiline,
|
||||||
commit.CommitSkipHooks,
|
commit.CommitSkipHooks,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user