mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-03-05 15:15:49 +02:00
use assert in tests, rename testing method
This commit is contained in:
parent
cff1dee6dc
commit
ca9ce22693
@ -2,11 +2,11 @@ package commands
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"strings"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/jesseduffield/lazygit/pkg/test"
|
"github.com/jesseduffield/lazygit/pkg/test"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
func newDummyLog() *logrus.Entry {
|
func newDummyLog() *logrus.Entry {
|
||||||
@ -22,11 +22,11 @@ func newDummyGitCommand() *GitCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDiff(t *testing.T) {
|
|
||||||
gitCommand := newDummyGitCommand()
|
|
||||||
if err := test.GenerateRepo("lots_of_diffs.sh"); err != nil {
|
|
||||||
t.Error(err.Error())
|
|
||||||
}
|
}
|
||||||
|
func TestGitCommandDiff(t *testing.T) {
|
||||||
|
gitCommand := newDummyGitCommand()
|
||||||
|
assert.NoError(t, test.GenerateRepo("lots_of_diffs.sh"))
|
||||||
|
|
||||||
files := []File{
|
files := []File{
|
||||||
{
|
{
|
||||||
Name: "deleted_staged",
|
Name: "deleted_staged",
|
||||||
@ -110,10 +110,8 @@ func TestDiff(t *testing.T) {
|
|||||||
DisplayString: "?? master",
|
DisplayString: "?? master",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, file := range files {
|
for _, file := range files {
|
||||||
content := gitCommand.Diff(file)
|
assert.NotContains(t, gitCommand.Diff(file), "error")
|
||||||
if strings.Contains(content, "error") {
|
|
||||||
t.Error("Error: diff test failed. File: " + file.Name + ", " + content)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user