mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-01-04 03:11:55 +02:00
test: gomod on old go version
refs #4280 Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
This commit is contained in:
parent
bb175015c7
commit
5c8b5ced67
@ -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)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user