1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2024-11-24 08:52:21 +02:00

this is so cool

This commit is contained in:
Jesse Duffield 2020-10-04 21:34:32 +11:00
parent f76196937a
commit b64c6a3ac7
4 changed files with 105 additions and 9 deletions

View File

@ -32,7 +32,7 @@ import (
type integrationTest struct {
name string
prepare func() error
prepare func(rootDir string) error
}
func generateSnapshot(t *testing.T) string {
@ -61,13 +61,17 @@ func findOrCreateDir(path string) {
func Test(t *testing.T) {
tests := []integrationTest{
// {
// name: "commit",
// prepare: createFixture1,
// },
// {
// name: "squash",
// prepare: createFixture2,
// },
{
name: "commit",
prepare: createFixture1,
},
{
name: "squash",
prepare: createFixture2,
name: "patchBuilding",
prepare: createFixture3,
},
}
@ -92,13 +96,13 @@ func Test(t *testing.T) {
prepareIntegrationTestDir()
err = test.prepare()
err = test.prepare(rootDir)
assert.NoError(t, err)
record := os.Getenv("RECORD_EVENTS") != ""
runLazygit(t, replayPath, record)
updateSnapshot := os.Getenv("UPDATE_SNAPSHOT") != ""
updateSnapshot := record || os.Getenv("UPDATE_SNAPSHOT") != ""
actual := generateSnapshot(t)
@ -148,6 +152,17 @@ func createFixture2() error {
return runCommands(cmds)
}
func createFixture3(rootDir string) error {
osCommand := oscommands.NewDummyOSCommand()
cmd := exec.Command("sh", filepath.Join(rootDir, "test", "fixtures", "1.sh"))
if err := osCommand.RunExecutable(cmd); err != nil {
return err
}
return nil
}
func runCommands(cmds []string) error {
osCommand := oscommands.NewDummyOSCommand()

17
test/fixtures/1.sh vendored Normal file
View File

@ -0,0 +1,17 @@
#!/bin/sh
git init
echo test1 > myfile1
git add .
git commit -am "myfile1"
echo firstline > myfile2
echo secondline >> myfile2
echo thirdline >> myfile2
git add .
git commit -am "myfile2"
echo firstline2 > myfile2
echo secondline >> myfile2
echo thirdline2 >> myfile2
git commit -am "myfile2 update"
echo test3 > myfile3
git add .
git commit -am "myfile3"

View File

@ -0,0 +1 @@
[{"Timestamp":34,"Event":{"Type":1,"Mod":0,"Key":0,"Ch":0,"Width":0,"Height":0,"Err":null,"MouseX":0,"MouseY":0,"N":0,"Bytes":null}},{"Timestamp":406,"Event":{"Type":0,"Mod":0,"Key":65514,"Ch":0,"Width":0,"Height":0,"Err":null,"MouseX":0,"MouseY":0,"N":3,"Bytes":"G09D"}},{"Timestamp":525,"Event":{"Type":0,"Mod":0,"Key":65514,"Ch":0,"Width":0,"Height":0,"Err":null,"MouseX":0,"MouseY":0,"N":3,"Bytes":"G09D"}},{"Timestamp":750,"Event":{"Type":0,"Mod":0,"Key":65516,"Ch":0,"Width":0,"Height":0,"Err":null,"MouseX":0,"MouseY":0,"N":3,"Bytes":"G09C"}},{"Timestamp":1046,"Event":{"Type":0,"Mod":0,"Key":13,"Ch":0,"Width":0,"Height":0,"Err":null,"MouseX":0,"MouseY":0,"N":1,"Bytes":"DQ=="}},{"Timestamp":1399,"Event":{"Type":0,"Mod":0,"Key":13,"Ch":0,"Width":0,"Height":0,"Err":null,"MouseX":0,"MouseY":0,"N":1,"Bytes":"DQ=="}},{"Timestamp":1990,"Event":{"Type":0,"Mod":0,"Key":32,"Ch":0,"Width":0,"Height":0,"Err":null,"MouseX":0,"MouseY":0,"N":1,"Bytes":"IA=="}},{"Timestamp":2253,"Event":{"Type":0,"Mod":0,"Key":65516,"Ch":0,"Width":0,"Height":0,"Err":null,"MouseX":0,"MouseY":0,"N":3,"Bytes":"G09C"}},{"Timestamp":2494,"Event":{"Type":0,"Mod":0,"Key":32,"Ch":0,"Width":0,"Height":0,"Err":null,"MouseX":0,"MouseY":0,"N":1,"Bytes":"IA=="}},{"Timestamp":3232,"Event":{"Type":0,"Mod":0,"Key":27,"Ch":0,"Width":0,"Height":0,"Err":null,"MouseX":0,"MouseY":0,"N":1,"Bytes":"Gw=="}},{"Timestamp":3415,"Event":{"Type":0,"Mod":0,"Key":27,"Ch":0,"Width":0,"Height":0,"Err":null,"MouseX":0,"MouseY":0,"N":1,"Bytes":"Gw=="}},{"Timestamp":3806,"Event":{"Type":0,"Mod":0,"Key":16,"Ch":0,"Width":0,"Height":0,"Err":null,"MouseX":0,"MouseY":0,"N":1,"Bytes":"EA=="}},{"Timestamp":4182,"Event":{"Type":0,"Mod":0,"Key":65516,"Ch":0,"Width":0,"Height":0,"Err":null,"MouseX":0,"MouseY":0,"N":3,"Bytes":"G09C"}},{"Timestamp":4302,"Event":{"Type":0,"Mod":0,"Key":65516,"Ch":0,"Width":0,"Height":0,"Err":null,"MouseX":0,"MouseY":0,"N":3,"Bytes":"G09C"}},{"Timestamp":4421,"Event":{"Type":0,"Mod":0,"Key":65516,"Ch":0,"Width":0,"Height":0,"Err":null,"MouseX":0,"MouseY":0,"N":3,"Bytes":"G09C"}},{"Timestamp":4558,"Event":{"Type":0,"Mod":0,"Key":65516,"Ch":0,"Width":0,"Height":0,"Err":null,"MouseX":0,"MouseY":0,"N":3,"Bytes":"G09C"}},{"Timestamp":4822,"Event":{"Type":0,"Mod":0,"Key":13,"Ch":0,"Width":0,"Height":0,"Err":null,"MouseX":0,"MouseY":0,"N":1,"Bytes":"DQ=="}},{"Timestamp":5332,"Event":{"Type":0,"Mod":0,"Key":65515,"Ch":0,"Width":0,"Height":0,"Err":null,"MouseX":0,"MouseY":0,"N":3,"Bytes":"G09E"}},{"Timestamp":5438,"Event":{"Type":0,"Mod":0,"Key":65515,"Ch":0,"Width":0,"Height":0,"Err":null,"MouseX":0,"MouseY":0,"N":3,"Bytes":"G09E"}},{"Timestamp":5726,"Event":{"Type":0,"Mod":0,"Key":0,"Ch":99,"Width":0,"Height":0,"Err":null,"MouseX":0,"MouseY":0,"N":1,"Bytes":"Yw=="}},{"Timestamp":6070,"Event":{"Type":0,"Mod":0,"Key":0,"Ch":116,"Width":0,"Height":0,"Err":null,"MouseX":0,"MouseY":0,"N":1,"Bytes":"dA=="}},{"Timestamp":6110,"Event":{"Type":0,"Mod":0,"Key":0,"Ch":101,"Width":0,"Height":0,"Err":null,"MouseX":0,"MouseY":0,"N":1,"Bytes":"ZQ=="}},{"Timestamp":6238,"Event":{"Type":0,"Mod":0,"Key":0,"Ch":115,"Width":0,"Height":0,"Err":null,"MouseX":0,"MouseY":0,"N":1,"Bytes":"cw=="}},{"Timestamp":6274,"Event":{"Type":0,"Mod":0,"Key":0,"Ch":116,"Width":0,"Height":0,"Err":null,"MouseX":0,"MouseY":0,"N":1,"Bytes":"dA=="}},{"Timestamp":6414,"Event":{"Type":0,"Mod":0,"Key":13,"Ch":0,"Width":0,"Height":0,"Err":null,"MouseX":0,"MouseY":0,"N":1,"Bytes":"DQ=="}},{"Timestamp":6870,"Event":{"Type":0,"Mod":0,"Key":0,"Ch":113,"Width":0,"Height":0,"Err":null,"MouseX":0,"MouseY":0,"N":1,"Bytes":"cQ=="}}]

View File

@ -0,0 +1,63 @@
On branch master
nothing to commit, working tree clean
test1
firstline2
secondline
thirdline2
test3
test
diff --git a/myfile2 b/myfile2
index 475a06b..5286367 100644
--- a/myfile2
+++ b/myfile2
@@ -1,3 +1,3 @@
-firstline
+firstline2
secondline
thirdline2
myfile3
diff --git a/myfile3 b/myfile3
new file mode 100644
index 0000000..df6b0d2
--- /dev/null
+++ b/myfile3
@@ -0,0 +1 @@
+test3
myfile2 update
diff --git a/myfile2 b/myfile2
index f3c8a07..475a06b 100644
--- a/myfile2
+++ b/myfile2
@@ -1,3 +1,3 @@
firstline
secondline
-thirdline
+thirdline2
myfile2
diff --git a/myfile2 b/myfile2
new file mode 100644
index 0000000..f3c8a07
--- /dev/null
+++ b/myfile2
@@ -0,0 +1,3 @@
+firstline
+secondline
+thirdline
myfile1
diff --git a/myfile1 b/myfile1
new file mode 100644
index 0000000..a5bce3f
--- /dev/null
+++ b/myfile1
@@ -0,0 +1 @@
+test1