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(
|
err := integration.RunTests(
|
||||||
t.Logf,
|
t.Logf,
|
||||||
runCmdHeadless,
|
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) {
|
t.Run(test.Name, func(t *testing.T) {
|
||||||
err := f()
|
err := f(t)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
updateSnapshots,
|
updateSnapshots,
|
||||||
record,
|
record,
|
||||||
speedEnv,
|
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))
|
assert.Equal(t, expected, actual, fmt.Sprintf("expected:\n%s\nactual:\n%s\n", expected, actual))
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
@ -9,6 +9,7 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
"testing"
|
||||||
|
|
||||||
"github.com/jesseduffield/lazygit/pkg/commands/oscommands"
|
"github.com/jesseduffield/lazygit/pkg/commands/oscommands"
|
||||||
"github.com/jesseduffield/lazygit/pkg/secureexec"
|
"github.com/jesseduffield/lazygit/pkg/secureexec"
|
||||||
@ -27,11 +28,11 @@ type Test struct {
|
|||||||
func RunTests(
|
func RunTests(
|
||||||
logf func(format string, formatArgs ...interface{}),
|
logf func(format string, formatArgs ...interface{}),
|
||||||
runCmd func(cmd *exec.Cmd) error,
|
runCmd func(cmd *exec.Cmd) error,
|
||||||
fnWrapper func(test *Test, f func() error),
|
fnWrapper func(test *Test, f func(*testing.T) error),
|
||||||
updateSnapshots bool,
|
updateSnapshots bool,
|
||||||
record bool,
|
record bool,
|
||||||
speedEnv string,
|
speedEnv string,
|
||||||
onFail func(expected string, actual string),
|
onFail func(t *testing.T, expected string, actual string),
|
||||||
) error {
|
) error {
|
||||||
rootDir := GetRootDirectory()
|
rootDir := GetRootDirectory()
|
||||||
err := os.Chdir(rootDir)
|
err := os.Chdir(rootDir)
|
||||||
@ -55,7 +56,7 @@ func RunTests(
|
|||||||
for _, test := range tests {
|
for _, test := range tests {
|
||||||
test := test
|
test := test
|
||||||
|
|
||||||
fnWrapper(test, func() error {
|
fnWrapper(test, func(t *testing.T) error {
|
||||||
speeds := getTestSpeeds(test.Speed, updateSnapshots, speedEnv)
|
speeds := getTestSpeeds(test.Speed, updateSnapshots, speedEnv)
|
||||||
testPath := filepath.Join(testDir, test.Name)
|
testPath := filepath.Join(testDir, test.Name)
|
||||||
actualDir := filepath.Join(testPath, "actual")
|
actualDir := filepath.Join(testPath, "actual")
|
||||||
@ -118,7 +119,7 @@ func RunTests(
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
logf("%s", string(bytes))
|
logf("%s", string(bytes))
|
||||||
onFail(expected, actual)
|
onFail(t, expected, actual)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
"testing"
|
||||||
|
|
||||||
"github.com/jesseduffield/lazygit/pkg/integration"
|
"github.com/jesseduffield/lazygit/pkg/integration"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
@ -27,18 +28,18 @@ func main() {
|
|||||||
err := integration.RunTests(
|
err := integration.RunTests(
|
||||||
log.Printf,
|
log.Printf,
|
||||||
runCmdInTerminal,
|
runCmdInTerminal,
|
||||||
func(test *integration.Test, f func() error) {
|
func(test *integration.Test, f func(*testing.T) error) {
|
||||||
if selectedTestName != "" && test.Name != selectedTestName {
|
if selectedTestName != "" && test.Name != selectedTestName {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if err := f(); err != nil {
|
if err := f(nil); err != nil {
|
||||||
log.Print(err.Error())
|
log.Print(err.Error())
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
updateSnapshots,
|
updateSnapshots,
|
||||||
record,
|
record,
|
||||||
speedEnv,
|
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))
|
assert.Equal(MockTestingT{}, expected, actual, fmt.Sprintf("expected:\n%s\nactual:\n%s\n", expected, actual))
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user