mirror of
https://github.com/kemko/nomad.git
synced 2026-01-06 18:35:44 +03:00
Fix error messages
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user