Fix error messages

This commit is contained in:
Kenjiro Nakayama
2016-08-17 17:02:43 +09:00
parent 7e1cc0599a
commit 7880222d39
4 changed files with 16 additions and 16 deletions

View File

@@ -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.

View File

@@ -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()
}

View File

@@ -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()
}

View File

@@ -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()