From 570efaa05b52adacf747b6080fb1f43e43f46644 Mon Sep 17 00:00:00 2001 From: Chris Baker Date: Fri, 12 Apr 2019 20:55:55 +0000 Subject: [PATCH] gofmt/goimport and test formatting --- command/job_periodic.go | 1 - command/job_periodic_force.go | 1 - command/job_periodic_force_test.go | 33 ++++++++++++------------------ 3 files changed, 13 insertions(+), 22 deletions(-) diff --git a/command/job_periodic.go b/command/job_periodic.go index 2c7d37ecb..020e2ab29 100644 --- a/command/job_periodic.go +++ b/command/job_periodic.go @@ -25,7 +25,6 @@ func (f *JobPeriodicCommand) Help() string { Usage: nomad job periodic [options] [args] This command groups subcommands for interacting with periodic jobs. - This command groups subcommands for interacting with periodic jobs. Force a periodic job: diff --git a/command/job_periodic_force.go b/command/job_periodic_force.go index 85e62ecd7..f11d35031 100644 --- a/command/job_periodic_force.go +++ b/command/job_periodic_force.go @@ -5,7 +5,6 @@ import ( "strings" "github.com/hashicorp/nomad/api" - "github.com/posener/complete" ) diff --git a/command/job_periodic_force_test.go b/command/job_periodic_force_test.go index 5387e5990..fc8caedc6 100644 --- a/command/job_periodic_force_test.go +++ b/command/job_periodic_force_test.go @@ -2,18 +2,16 @@ package command import ( "fmt" - "strings" "testing" "github.com/hashicorp/nomad/api" "github.com/hashicorp/nomad/helper" - "github.com/hashicorp/nomad/nomad/structs" - "github.com/stretchr/testify/require" - "github.com/hashicorp/nomad/nomad/mock" + "github.com/hashicorp/nomad/nomad/structs" "github.com/hashicorp/nomad/testutil" "github.com/mitchellh/cli" "github.com/posener/complete" + "github.com/stretchr/testify/require" ) func TestJobPeriodicForceCommand_Implements(t *testing.T) { @@ -27,21 +25,16 @@ func TestJobPeriodicForceCommand_Fails(t *testing.T) { cmd := &JobPeriodicForceCommand{Meta: Meta{Ui: ui}} // Fails on misuse - if code := cmd.Run([]string{"some", "bad", "args"}); code != 1 { - t.Fatalf("expected exit code 1, got: %d", code) - } - if out := ui.ErrorWriter.String(); !strings.Contains(out, commandErrorText(cmd)) { - t.Fatalf("expected help output, got: %s", out) - } + code := cmd.Run([]string{"some", "bad", "args"}) + require.Equal(t, code, 1, "expected error") + out := ui.ErrorWriter.String() + require.Contains(t, out, commandErrorText(cmd), "expected help output") ui.ErrorWriter.Reset() - if code := cmd.Run([]string{"-address=nope", "12"}); code != 1 { - t.Fatalf("expected exit code 1, got: %d", code) - } - if out := ui.ErrorWriter.String(); !strings.Contains(out, "Error forcing periodic job") { - t.Fatalf("expected failed to force error, got: %s", out) - } - ui.ErrorWriter.Reset() + code = cmd.Run([]string{"-address=nope", "12"}) + require.Equal(t, code, 1, "expected error") + out = ui.ErrorWriter.String() + require.Contains(t, out, "Error forcing periodic job", "expected force error") } func TestJobPeriodicForceCommand_AutocompleteArgs(t *testing.T) { @@ -99,7 +92,7 @@ func TestJobPeriodicForceCommand_NonPeriodicJob(t *testing.T) { } return true, nil }, func(err error) { - t.Fatalf("err: %s", err) + require.NoError(t, err) }) // Register a job @@ -136,7 +129,7 @@ func TestJobPeriodicForceCommand_SuccessfulPeriodicForceDetach(t *testing.T) { } return true, nil }, func(err error) { - t.Fatalf("err: %s", err) + require.NoError(t, err) }) // Register a job @@ -178,7 +171,7 @@ func TestJobPeriodicForceCommand_SuccessfulPeriodicForce(t *testing.T) { } return true, nil }, func(err error) { - t.Fatalf("err: %s", err) + require.NoError(t, err) }) // Register a job