diff --git a/pipeline/build_golang_test.go b/pipeline/build_golang_test.go index 8d258b83..f0eb1b53 100644 --- a/pipeline/build_golang_test.go +++ b/pipeline/build_golang_test.go @@ -96,6 +96,40 @@ func TestExecuteBuild(t *testing.T) { } } +func TestExecuteBuildFailPipelineBuild(t *testing.T) { + os.Mkdir("tmp", 0744) + ioutil.WriteFile(filepath.Join("tmp", "main.go"), []byte(`package main + import "os" + func main() { + os.Exit(1 + }`), 0766) + wd, _ := os.Getwd() + tmp := filepath.Join(wd, "tmp") + defer func() { + os.RemoveAll(tmp) + }() + gaia.Cfg = new(gaia.Config) + gaia.Cfg.HomePath = tmp + gaia.Cfg.Logger = hclog.New(&hclog.LoggerOptions{ + Level: hclog.Trace, + Output: hclog.DefaultOutput, + Name: "Gaia", + }) + b := new(BuildPipelineGolang) + p := new(gaia.CreatePipeline) + p.Pipeline.Repo.LocalDest = tmp + err := b.ExecuteBuild(p) + if err == nil { + t.Fatal("error while running executebuild. none was expected") + } + expected := `# _/Users/gbrautigam/gohome/src/github.com/gaia-pipeline/gaia/pipeline/tmp +./main.go:4:13: syntax error: unexpected newline, expecting comma or ) +` + if p.Output != expected { + t.Fatal("got a different output than expected: ", p.Output) + } +} + func TestExecuteBuildContextTimeout(t *testing.T) { execCommandContext = fakeExecCommandContext killContext = true