mirror of
https://github.com/jesseduffield/lazygit.git
synced 2024-11-24 08:52:21 +02:00
ensure we're passing the right testing struct pointer around
This commit is contained in:
parent
0719a3e36e
commit
fb9b6314a0
@ -43,16 +43,16 @@ func Test(t *testing.T) {
|
||||
err := integration.RunTests(
|
||||
t.Logf,
|
||||
runCmdHeadless,
|
||||
func(test *integration.Test, f func() error) {
|
||||
func(test *integration.Test, f func(*testing.T) error) {
|
||||
t.Run(test.Name, func(t *testing.T) {
|
||||
err := f()
|
||||
err := f(t)
|
||||
assert.NoError(t, err)
|
||||
})
|
||||
},
|
||||
updateSnapshots,
|
||||
record,
|
||||
speedEnv,
|
||||
func(expected string, actual string) {
|
||||
func(t *testing.T, expected string, actual string) {
|
||||
assert.Equal(t, expected, actual, fmt.Sprintf("expected:\n%s\nactual:\n%s\n", expected, actual))
|
||||
},
|
||||
)
|
||||
|
@ -9,6 +9,7 @@ import (
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/jesseduffield/lazygit/pkg/commands/oscommands"
|
||||
"github.com/jesseduffield/lazygit/pkg/secureexec"
|
||||
@ -27,11 +28,11 @@ type Test struct {
|
||||
func RunTests(
|
||||
logf func(format string, formatArgs ...interface{}),
|
||||
runCmd func(cmd *exec.Cmd) error,
|
||||
fnWrapper func(test *Test, f func() error),
|
||||
fnWrapper func(test *Test, f func(*testing.T) error),
|
||||
updateSnapshots bool,
|
||||
record bool,
|
||||
speedEnv string,
|
||||
onFail func(expected string, actual string),
|
||||
onFail func(t *testing.T, expected string, actual string),
|
||||
) error {
|
||||
rootDir := GetRootDirectory()
|
||||
err := os.Chdir(rootDir)
|
||||
@ -55,7 +56,7 @@ func RunTests(
|
||||
for _, test := range tests {
|
||||
test := test
|
||||
|
||||
fnWrapper(test, func() error {
|
||||
fnWrapper(test, func(t *testing.T) error {
|
||||
speeds := getTestSpeeds(test.Speed, updateSnapshots, speedEnv)
|
||||
testPath := filepath.Join(testDir, test.Name)
|
||||
actualDir := filepath.Join(testPath, "actual")
|
||||
@ -118,7 +119,7 @@ func RunTests(
|
||||
return err
|
||||
}
|
||||
logf("%s", string(bytes))
|
||||
onFail(expected, actual)
|
||||
onFail(t, expected, actual)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,7 @@ import (
|
||||
"log"
|
||||
"os"
|
||||
"os/exec"
|
||||
"testing"
|
||||
|
||||
"github.com/jesseduffield/lazygit/pkg/integration"
|
||||
"github.com/stretchr/testify/assert"
|
||||
@ -27,18 +28,18 @@ func main() {
|
||||
err := integration.RunTests(
|
||||
log.Printf,
|
||||
runCmdInTerminal,
|
||||
func(test *integration.Test, f func() error) {
|
||||
func(test *integration.Test, f func(*testing.T) error) {
|
||||
if selectedTestName != "" && test.Name != selectedTestName {
|
||||
return
|
||||
}
|
||||
if err := f(); err != nil {
|
||||
if err := f(nil); err != nil {
|
||||
log.Print(err.Error())
|
||||
}
|
||||
},
|
||||
updateSnapshots,
|
||||
record,
|
||||
speedEnv,
|
||||
func(expected string, actual string) {
|
||||
func(_t *testing.T, expected string, actual string) {
|
||||
assert.Equal(MockTestingT{}, expected, actual, fmt.Sprintf("expected:\n%s\nactual:\n%s\n", expected, actual))
|
||||
},
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user