summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pkg/gui/gui_test.go71
-rw-r--r--test/fixtures/manyCommits.sh17
-rw-r--r--test/fixtures/newFile.sh15
-rw-r--r--test/fixtures/updatedFile.sh (renamed from test/fixtures/1.sh)0
-rw-r--r--test/integration/commit/snapshot.txt54
5 files changed, 94 insertions, 63 deletions
diff --git a/pkg/gui/gui_test.go b/pkg/gui/gui_test.go
index e9bf36976..371cf1397 100644
--- a/pkg/gui/gui_test.go
+++ b/pkg/gui/gui_test.go
@@ -8,7 +8,6 @@ import (
"path/filepath"
"testing"
- "github.com/go-errors/errors"
"github.com/jesseduffield/lazygit/pkg/commands/oscommands"
"github.com/stretchr/testify/assert"
)
@@ -32,7 +31,7 @@ import (
type integrationTest struct {
name string
- prepare func(rootDir string) error
+ fixture string
}
func generateSnapshot(t *testing.T) string {
@@ -61,17 +60,17 @@ func findOrCreateDir(path string) {
func Test(t *testing.T) {
tests := []integrationTest{
- // {
- // name: "commit",
- // prepare: createFixture1,
- // },
- // {
- // name: "squash",
- // prepare: createFixture2,
- // },
+ {
+ name: "commit",
+ fixture: "newFile",
+ },
+ {
+ name: "squash",
+ fixture: "manyCommits",
+ },
{
name: "patchBuilding",
- prepare: createFixture3,
+ fixture: "updatedFile",
},
}
@@ -96,7 +95,7 @@ func Test(t *testing.T) {
prepareIntegrationTestDir()
- err = test.prepare(rootDir)
+ err = createFixture(rootDir, test.fixture)
assert.NoError(t, err)
record := os.Getenv("RECORD_EVENTS") != ""
@@ -120,41 +119,9 @@ func Test(t *testing.T) {
}
}
-func createFixture1() error {
- cmds := []string{
- "git init",
- `sh -c "echo test > myfile"`,
- }
-
- return runCommands(cmds)
-}
-
-func createFixture2() error {
- cmds := []string{
- "git init",
- `sh -c "echo test1 > myfile1"`,
- `git add .`,
- `git commit -am "myfile1"`,
- `sh -c "echo test2 > myfile2"`,
- `git add .`,
- `git commit -am "myfile2"`,
- `sh -c "echo test3 > myfile3"`,
- `git add .`,
- `git commit -am "myfile3"`,
- `sh -c "echo test4 > myfile4"`,
- `git add .`,
- `git commit -am "myfile4"`,
- `sh -c "echo test5 > myfile5"`,
- `git add .`,
- `git commit -am "myfile5"`,
- }
-
- return runCommands(cmds)
-}
-
-func createFixture3(rootDir string) error {
+func createFixture(rootDir string, name string) error {
osCommand := oscommands.NewDummyOSCommand()
- cmd := exec.Command("sh", filepath.Join(rootDir, "test", "fixtures", "1.sh"))
+ cmd := exec.Command("sh", filepath.Join(rootDir, "test", "fixtures", fmt.Sprintf("%s.sh", name)))
if err := osCommand.RunExecutable(cmd); err != nil {
return err
@@ -163,18 +130,6 @@ func createFixture3(rootDir string) error {
return nil
}
-func runCommands(cmds []string) error {
- osCommand := oscommands.NewDummyOSCommand()
-
- for _, cmd := range cmds {
- if err := osCommand.RunCommand(cmd); err != nil {
- return errors.New(fmt.Sprintf("error running command `%s`: %v", cmd, err))
- }
- }
-
- return nil
-}
-
func gotoRootDirectory() {
for {
_, err := os.Stat(".git")
diff --git a/test/fixtures/manyCommits.sh b/test/fixtures/manyCommits.sh
new file mode 100644
index 000000000..8eec5ae57
--- /dev/null
+++ b/test/fixtures/manyCommits.sh
@@ -0,0 +1,17 @@
+#!/bin/sh
+git init
+echo test1 > myfile1
+git add .
+git commit -am "myfile1"
+echo test2 > myfile2
+git add .
+git commit -am "myfile2"
+echo test3 > myfile3
+git add .
+git commit -am "myfile3"
+echo test4 > myfile4
+git add .
+git commit -am "myfile4"
+echo test5 > myfile5
+git add .
+git commit -am "myfile5"
diff --git a/test/fixtures/newFile.sh b/test/fixtures/newFile.sh
new file mode 100644
index 000000000..f8592c33f
--- /dev/null
+++ b/test/fixtures/newFile.sh
@@ -0,0 +1,15 @@
+#!/bin/sh
+git init
+echo test1 > myfile1
+git add .
+git commit -am "myfile1"
+echo test2 > myfile2
+git add .
+git commit -am "myfile2"
+echo test3 > myfile3
+git add .
+git commit -am "myfile3"
+echo test4 > myfile4
+git add .
+git commit -am "myfile4"
+echo test5 > myfile5
diff --git a/test/fixtures/1.sh b/test/fixtures/updatedFile.sh
index 2c42d6282..2c42d6282 100644
--- a/test/fixtures/1.sh
+++ b/test/fixtures/updatedFile.sh
diff --git a/test/integration/commit/snapshot.txt b/test/integration/commit/snapshot.txt
index 0c50ae828..31c1e5553 100644
--- a/test/integration/commit/snapshot.txt
+++ b/test/integration/commit/snapshot.txt
@@ -1,13 +1,57 @@
On branch master
nothing to commit, working tree clean
-test
+test1
+test2
+test3
+test4
+test5
my commit
-diff --git a/myfile b/myfile
+diff --git a/myfile5 b/myfile5
new file mode 100644
-index 0000000..9daeafb
+index 0000000..4f346f1
--- /dev/null
-+++ b/myfile
++++ b/myfile5
@@ -0,0 +1 @@
-+test
++test5
+myfile4
+
+
+diff --git a/myfile4 b/myfile4
+new file mode 100644
+index 0000000..d234c5e
+--- /dev/null
++++ b/myfile4
+@@ -0,0 +1 @@
++test4
+myfile3
+
+
+diff --git a/myfile3 b/myfile3
+new file mode 100644
+index 0000000..df6b0d2
+--- /dev/null
++++ b/myfile3
+@@ -0,0 +1 @@
++test3
+myfile2
+
+
+diff --git a/myfile2 b/myfile2
+new file mode 100644
+index 0000000..180cf83
+--- /dev/null
++++ b/myfile2
+@@ -0,0 +1 @@
++test2
+myfile1
+
+
+diff --git a/myfile1 b/myfile1
+new file mode 100644
+index 0000000..a5bce3f
+--- /dev/null
++++ b/myfile1
+@@ -0,0 +1 @@
++test1