From 7880222d394af1ed2abde8a70f9b3b008c7b6e93 Mon Sep 17 00:00:00 2001 From: Kenjiro Nakayama Date: Wed, 17 Aug 2016 17:02:43 +0900 Subject: [PATCH] Fix error messages --- command/plan.go | 2 +- command/plan_test.go | 12 ++++++------ command/run_test.go | 10 +++++----- command/validate_test.go | 8 ++++---- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/command/plan.go b/command/plan.go index 717ae255c..412a3e3e6 100644 --- a/command/plan.go +++ b/command/plan.go @@ -102,7 +102,7 @@ func (c *PlanCommand) Run(args []string) int { job, err := c.JobGetter.StructJob(args[0]) if err != nil { c.Ui.Error(fmt.Sprintf("Error getting job struct: %s", err)) - return 1 + return 255 } // Initialize any fields that need to be. diff --git a/command/plan_test.go b/command/plan_test.go index 4cdc15ceb..79793301e 100644 --- a/command/plan_test.go +++ b/command/plan_test.go @@ -30,8 +30,8 @@ func TestPlanCommand_Fails(t *testing.T) { if code := cmd.Run([]string{"/unicorns/leprechauns"}); code != 255 { t.Fatalf("expect exit 1, got: %d", code) } - if out := ui.ErrorWriter.String(); !strings.Contains(out, "Error opening") { - t.Fatalf("expect parsing error, got: %s", out) + if out := ui.ErrorWriter.String(); !strings.Contains(out, "Error getting job struct") { + t.Fatalf("expect getting job struct error, got: %s", out) } ui.ErrorWriter.Reset() @@ -47,8 +47,8 @@ func TestPlanCommand_Fails(t *testing.T) { if code := cmd.Run([]string{fh1.Name()}); code != 255 { t.Fatalf("expect exit 1, got: %d", code) } - if out := ui.ErrorWriter.String(); !strings.Contains(out, "Error parsing") { - t.Fatalf("expect parsing error, got: %s", err) + if out := ui.ErrorWriter.String(); !strings.Contains(out, "Error getting job struct") { + t.Fatalf("expect parsing error, got: %s", out) } ui.ErrorWriter.Reset() @@ -136,11 +136,11 @@ job "job1" { args := []string{"-"} if code := cmd.Run(args); code != 255 { - t.Fatalf("expected exit code 1, got %d: %q", code, ui.ErrorWriter.String()) + t.Fatalf("expected exit code 255, got %d: %q", code, ui.ErrorWriter.String()) } if out := ui.ErrorWriter.String(); !strings.Contains(out, "connection refused") { - t.Fatalf("expected runtime error, got: %s", out) + t.Fatalf("expected connection refused error, got: %s", out) } ui.ErrorWriter.Reset() } diff --git a/command/run_test.go b/command/run_test.go index 5c8dc10dc..840925e45 100644 --- a/command/run_test.go +++ b/command/run_test.go @@ -66,8 +66,8 @@ func TestRunCommand_Fails(t *testing.T) { if code := cmd.Run([]string{"/unicorns/leprechauns"}); code != 1 { t.Fatalf("expect exit 1, got: %d", code) } - if out := ui.ErrorWriter.String(); !strings.Contains(out, "Error opening") { - t.Fatalf("expect parsing error, got: %s", out) + if out := ui.ErrorWriter.String(); !strings.Contains(out, "Error getting job struct") { + t.Fatalf("expect getting job struct error, got: %s", out) } ui.ErrorWriter.Reset() @@ -83,8 +83,8 @@ func TestRunCommand_Fails(t *testing.T) { if code := cmd.Run([]string{fh1.Name()}); code != 1 { t.Fatalf("expect exit 1, got: %d", code) } - if out := ui.ErrorWriter.String(); !strings.Contains(out, "Error parsing") { - t.Fatalf("expect parsing error, got: %s", err) + if out := ui.ErrorWriter.String(); !strings.Contains(out, "Error getting job struct") { + t.Fatalf("expect parsing error, got: %s", out) } ui.ErrorWriter.Reset() @@ -186,7 +186,7 @@ job "job1" { } if out := ui.ErrorWriter.String(); !strings.Contains(out, "connection refused") { - t.Fatalf("expected runtime error, got: %s", out) + t.Fatalf("expected connection refused error, got: %s", out) } ui.ErrorWriter.Reset() } diff --git a/command/validate_test.go b/command/validate_test.go index a3f3b7916..ff9f42b5e 100644 --- a/command/validate_test.go +++ b/command/validate_test.go @@ -63,8 +63,8 @@ func TestValidateCommand_Fails(t *testing.T) { if code := cmd.Run([]string{"/unicorns/leprechauns"}); code != 1 { t.Fatalf("expect exit 1, got: %d", code) } - if out := ui.ErrorWriter.String(); !strings.Contains(out, "Error opening") { - t.Fatalf("expect parsing error, got: %s", out) + if out := ui.ErrorWriter.String(); !strings.Contains(out, "Error getting job struct") { + t.Fatalf("expect getting job struct error, got: %s", out) } ui.ErrorWriter.Reset() @@ -80,8 +80,8 @@ func TestValidateCommand_Fails(t *testing.T) { if code := cmd.Run([]string{fh1.Name()}); code != 1 { t.Fatalf("expect exit 1, got: %d", code) } - if out := ui.ErrorWriter.String(); !strings.Contains(out, "Error parsing") { - t.Fatalf("expect parsing error, got: %s", err) + if out := ui.ErrorWriter.String(); !strings.Contains(out, "Error getting job struct") { + t.Fatalf("expect parsing error, got: %s", out) } ui.ErrorWriter.Reset()