diff --git a/internal/pipe/gomod/gomod_test.go b/internal/pipe/gomod/gomod_test.go index 92d6639af..4a0288e96 100644 --- a/internal/pipe/gomod/gomod_test.go +++ b/internal/pipe/gomod/gomod_test.go @@ -31,7 +31,11 @@ func TestRunCustomMod(t *testing.T) { func TestCustomEnv(t *testing.T) { bin := filepath.Join(t.TempDir(), "go.bin") - require.NoError(t, os.WriteFile(bin, []byte("#!/bin/sh\nenv | grep -qw FOO=bar"), 0o755)) + require.NoError(t, os.WriteFile( + bin, + []byte("#!/bin/sh\nenv | grep -qw FOO=bar"), + 0o755, + )) ctx := testctx.NewWithCfg(config.Project{ GoMod: config.GoMod{ GoBinary: bin, @@ -44,20 +48,44 @@ func TestCustomEnv(t *testing.T) { func TestRunOutsideGoModule(t *testing.T) { dir := testlib.Mktmp(t) - require.NoError(t, os.WriteFile(filepath.Join(dir, "main.go"), []byte("package main\nfunc main() {println(0)}"), 0o666)) + require.NoError(t, os.WriteFile( + filepath.Join(dir, "main.go"), + []byte("package main\nfunc main() {println(0)}"), + 0o666, + )) ctx := testctx.New() require.NoError(t, Pipe{}.Default(ctx)) testlib.AssertSkipped(t, Pipe{}.Run(ctx)) require.Empty(t, ctx.ModulePath) } -func TestRunCommandError(t *testing.T) { +func TestRunOldGoVersion(t *testing.T) { ctx := testctx.NewWithCfg(config.Project{ GoMod: config.GoMod{ GoBinary: "not-a-valid-binary", }, }) - require.EqualError(t, Pipe{}.Run(ctx), "failed to get module path: exec: \"not-a-valid-binary\": executable file not found in $PATH: ") + require.EqualError( + t, + Pipe{}.Run(ctx), + `failed to get module path: exec: "not-a-valid-binary": executable file not found in $PATH: `, + ) + require.Empty(t, ctx.ModulePath) +} + +func TestRunCommandError(t *testing.T) { + bin := filepath.Join(t.TempDir(), "go.bin") + require.NoError(t, os.WriteFile( + bin, + []byte(`#!/bin/sh\necho "flag provided but not defined: -m"\nexit 1`), + 0o755, + )) + ctx := testctx.NewWithCfg(config.Project{ + GoMod: config.GoMod{ + GoBinary: bin, + }, + }) + testlib.AssertSkipped(t, Pipe{}.Run(ctx)) require.Empty(t, ctx.ModulePath) }