summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2020-10-04 21:34:32 +1100
committerJesse Duffield <jessedduffield@gmail.com>2020-10-10 00:23:01 +1100
commitb64c6a3ac723b4804849bcbbd70f144640bfddd9 (patch)
tree0658ef56f5a96b6431bdfc9882c347a3d3ba8000
parentf76196937a6d4e5dfe86736ab06f521180a0c7ce (diff)
this is so cool
-rw-r--r--pkg/gui/gui_test.go33
-rw-r--r--test/fixtures/1.sh17
-rw-r--r--test/integration/patchBuilding/recording.json1
-rw-r--r--test/integration/patchBuilding/snapshot.txt63
4 files changed, 105 insertions, 9 deletions
diff --git a/pkg/gui/gui_test.go b/pkg/gui/gui_test.go
index d0a22710a..e9bf36976 100644
--- a/pkg/gui/gui_test.go
+++ b/pkg/gui/gui_test.go
@@ -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()
diff --git a/test/fixtures/1.sh b/test/fixtures/1.sh
new file mode 100644
index 000000000..2c42d6282
--- /dev/null
+++ b/test/fixtures/1.sh
@@ -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"
diff --git a/test/integration/patchBuilding/recording.json b/test/integration/patchBuilding/recording.json
new file mode 100644
index 000000000..a5e3cda09
--- /dev/null
+++ b/test/integration/patchBuilding/recording.json
@@ -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=="}}] \ No newline at end of file
diff --git a/test/integration/patchBuilding/snapshot.txt b/test/integration/patchBuilding/snapshot.txt
new file mode 100644
index 000000000..7b2fc0690
--- /dev/null
+++ b/test/integration/patchBuilding/snapshot.txt
@@ -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