This commit is contained in:
Alex Dadgar 2017-07-20 21:24:21 -07:00
parent c106df9215
commit d7fee07ebc
41 changed files with 99 additions and 1 deletions

View File

@ -8,10 +8,12 @@ import (
)
func TestAgentInfoCommand_Implements(t *testing.T) {
t.Parallel()
var _ cli.Command = &AgentInfoCommand{}
}
func TestAgentInfoCommand_Run(t *testing.T) {
t.Parallel()
srv, _, url := testServer(t, false, nil)
defer srv.Shutdown()
@ -25,6 +27,7 @@ func TestAgentInfoCommand_Run(t *testing.T) {
}
func TestAgentInfoCommand_Fails(t *testing.T) {
t.Parallel()
ui := new(cli.MockUi)
cmd := &AgentInfoCommand{Meta: Meta{Ui: ui}}

View File

@ -11,10 +11,12 @@ import (
)
func TestAllocStatusCommand_Implements(t *testing.T) {
t.Parallel()
var _ cli.Command = &AllocStatusCommand{}
}
func TestAllocStatusCommand_Fails(t *testing.T) {
t.Parallel()
srv, _, url := testServer(t, false, nil)
defer srv.Shutdown()
@ -76,6 +78,7 @@ func TestAllocStatusCommand_Fails(t *testing.T) {
}
func TestAllocStatusCommand_Run(t *testing.T) {
t.Parallel()
srv, client, url := testServer(t, true, nil)
defer srv.Shutdown()

View File

@ -8,6 +8,7 @@ import (
)
func TestAgentCheckCommand_ServerHealth(t *testing.T) {
t.Parallel()
srv, _, url := testServer(t, false, nil)
defer srv.Shutdown()

View File

@ -9,10 +9,12 @@ import (
)
func TestClientConfigCommand_Implements(t *testing.T) {
t.Parallel()
var _ cli.Command = &ClientConfigCommand{}
}
func TestClientConfigCommand_UpdateServers(t *testing.T) {
t.Parallel()
srv, _, url := testServer(t, true, func(c *agent.Config) {
c.Server.BootstrapExpect = 0
})
@ -52,6 +54,7 @@ func TestClientConfigCommand_UpdateServers(t *testing.T) {
}
func TestClientConfigCommand_Fails(t *testing.T) {
t.Parallel()
ui := new(cli.MockUi)
cmd := &ClientConfigCommand{Meta: Meta{Ui: ui}}

View File

@ -24,6 +24,7 @@ var (
)
func TestDataFormat(t *testing.T) {
t.Parallel()
for k, v := range testFormat {
fm, err := DataFormat(k, v)
if err != nil {
@ -42,6 +43,7 @@ func TestDataFormat(t *testing.T) {
}
func TestInvalidJSONTemplate(t *testing.T) {
t.Parallel()
// Invalid template {{.foo}}
fm, err := DataFormat("template", "{{.foo}}")
if err != nil {

View File

@ -8,10 +8,12 @@ import (
)
func TestDeploymentFailCommand_Implements(t *testing.T) {
t.Parallel()
var _ cli.Command = &DeploymentFailCommand{}
}
func TestDeploymentFailCommand_Fails(t *testing.T) {
t.Parallel()
ui := new(cli.MockUi)
cmd := &DeploymentFailCommand{Meta: Meta{Ui: ui}}

View File

@ -8,10 +8,12 @@ import (
)
func TestDeploymentListCommand_Implements(t *testing.T) {
t.Parallel()
var _ cli.Command = &DeploymentListCommand{}
}
func TestDeploymentListCommand_Fails(t *testing.T) {
t.Parallel()
ui := new(cli.MockUi)
cmd := &DeploymentListCommand{Meta: Meta{Ui: ui}}

View File

@ -8,10 +8,12 @@ import (
)
func TestDeploymentPauseCommand_Implements(t *testing.T) {
t.Parallel()
var _ cli.Command = &DeploymentPauseCommand{}
}
func TestDeploymentPauseCommand_Fails(t *testing.T) {
t.Parallel()
ui := new(cli.MockUi)
cmd := &DeploymentPauseCommand{Meta: Meta{Ui: ui}}

View File

@ -8,10 +8,12 @@ import (
)
func TestDeploymentPromoteCommand_Implements(t *testing.T) {
t.Parallel()
var _ cli.Command = &DeploymentPromoteCommand{}
}
func TestDeploymentPromoteCommand_Fails(t *testing.T) {
t.Parallel()
ui := new(cli.MockUi)
cmd := &DeploymentPromoteCommand{Meta: Meta{Ui: ui}}

View File

@ -8,10 +8,12 @@ import (
)
func TestDeploymentResumeCommand_Implements(t *testing.T) {
t.Parallel()
var _ cli.Command = &DeploymentResumeCommand{}
}
func TestDeploymentResumeCommand_Fails(t *testing.T) {
t.Parallel()
ui := new(cli.MockUi)
cmd := &DeploymentResumeCommand{Meta: Meta{Ui: ui}}

View File

@ -8,10 +8,12 @@ import (
)
func TestDeploymentStatusCommand_Implements(t *testing.T) {
t.Parallel()
var _ cli.Command = &DeploymentStatusCommand{}
}
func TestDeploymentStatusCommand_Fails(t *testing.T) {
t.Parallel()
ui := new(cli.MockUi)
cmd := &DeploymentStatusCommand{Meta: Meta{Ui: ui}}

View File

@ -8,10 +8,12 @@ import (
)
func TestEvalStatusCommand_Implements(t *testing.T) {
t.Parallel()
var _ cli.Command = &EvalStatusCommand{}
}
func TestEvalStatusCommand_Fails(t *testing.T) {
t.Parallel()
srv, _, url := testServer(t, false, nil)
defer srv.Shutdown()

View File

@ -8,10 +8,12 @@ import (
)
func TestFSCommand_Implements(t *testing.T) {
t.Parallel()
var _ cli.Command = &FSCommand{}
}
func TestFSCommand_Fails(t *testing.T) {
t.Parallel()
srv, _, url := testServer(t, false, nil)
defer srv.Shutdown()

View File

@ -19,6 +19,7 @@ import (
)
func TestHelpers_FormatKV(t *testing.T) {
t.Parallel()
in := []string{"alpha|beta", "charlie|delta", "echo|"}
out := formatKV(in)
@ -32,6 +33,7 @@ func TestHelpers_FormatKV(t *testing.T) {
}
func TestHelpers_FormatList(t *testing.T) {
t.Parallel()
in := []string{"alpha|beta||delta"}
out := formatList(in)
@ -43,6 +45,7 @@ func TestHelpers_FormatList(t *testing.T) {
}
func TestHelpers_NodeID(t *testing.T) {
t.Parallel()
srv, _, _ := testServer(t, false, nil)
defer srv.Shutdown()
@ -59,6 +62,7 @@ func TestHelpers_NodeID(t *testing.T) {
}
func TestHelpers_LineLimitReader_NoTimeLimit(t *testing.T) {
t.Parallel()
helloString := `hello
world
this
@ -160,6 +164,7 @@ func (t *testReadCloser) Close() error {
}
func TestHelpers_LineLimitReader_TimeLimit(t *testing.T) {
t.Parallel()
// Create the test reader
in := &testReadCloser{data: make(chan []byte)}
@ -242,6 +247,7 @@ var (
// Test APIJob with local jobfile
func TestJobGetter_LocalFile(t *testing.T) {
t.Parallel()
fh, err := ioutil.TempFile("", "nomad")
if err != nil {
t.Fatalf("err: %s", err)
@ -267,6 +273,7 @@ func TestJobGetter_LocalFile(t *testing.T) {
// Test StructJob with jobfile from HTTP Server
func TestJobGetter_HTTPServer(t *testing.T) {
t.Parallel()
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, job)
})

View File

@ -10,10 +10,12 @@ import (
)
func TestInitCommand_Implements(t *testing.T) {
t.Parallel()
var _ cli.Command = &InitCommand{}
}
func TestInitCommand_Run(t *testing.T) {
t.Parallel()
ui := new(cli.MockUi)
cmd := &InitCommand{Meta: Meta{Ui: ui}}
@ -65,6 +67,7 @@ func TestInitCommand_Run(t *testing.T) {
}
func TestInitCommand_defaultJob(t *testing.T) {
t.Parallel()
// Ensure the job file is always written with spaces instead of tabs. Since
// the default job file is embedded in the go file, it's easy for tabs to
// slip in.

View File

@ -8,10 +8,12 @@ import (
)
func TestInspectCommand_Implements(t *testing.T) {
t.Parallel()
var _ cli.Command = &InspectCommand{}
}
func TestInspectCommand_Fails(t *testing.T) {
t.Parallel()
srv, _, url := testServer(t, false, nil)
defer srv.Shutdown()

View File

@ -8,6 +8,7 @@ import (
)
func TestIntegration_Command_NomadInit(t *testing.T) {
t.Parallel()
tmpDir, err := ioutil.TempDir("", "nomadtest-rootsecretdir")
if err != nil {
t.Fatalf("unable to create tempdir for test: %v", err)
@ -25,7 +26,7 @@ func TestIntegration_Command_NomadInit(t *testing.T) {
{
cmd := exec.Command("nomad", "validate", "example.nomad")
cmd.Dir = tmpDir
cmd.Env = []string{`NOMAD_ADDR=http://127.0.0.2:1025`}
cmd.Env = []string{`NOMAD_ADDR=http://127.0.0.1:0`}
if err := cmd.Run(); err != nil {
t.Fatalf("error validating example.nomad: %v", err)
}

View File

@ -8,10 +8,12 @@ import (
)
func TestJobDeploymentsCommand_Implements(t *testing.T) {
t.Parallel()
var _ cli.Command = &JobDeploymentsCommand{}
}
func TestJobDeploymentsCommand_Fails(t *testing.T) {
t.Parallel()
ui := new(cli.MockUi)
cmd := &JobDeploymentsCommand{Meta: Meta{Ui: ui}}

View File

@ -8,10 +8,12 @@ import (
)
func TestJobDispatchCommand_Implements(t *testing.T) {
t.Parallel()
var _ cli.Command = &JobDispatchCommand{}
}
func TestJobDispatchCommand_Fails(t *testing.T) {
t.Parallel()
ui := new(cli.MockUi)
cmd := &JobDispatchCommand{Meta: Meta{Ui: ui}}

View File

@ -8,10 +8,12 @@ import (
)
func TestJobHistoryCommand_Implements(t *testing.T) {
t.Parallel()
var _ cli.Command = &JobDispatchCommand{}
}
func TestJobHistoryCommand_Fails(t *testing.T) {
t.Parallel()
ui := new(cli.MockUi)
cmd := &JobHistoryCommand{Meta: Meta{Ui: ui}}

View File

@ -8,10 +8,12 @@ import (
)
func TestJobPromoteCommand_Implements(t *testing.T) {
t.Parallel()
var _ cli.Command = &JobPromoteCommand{}
}
func TestJobPromoteCommand_Fails(t *testing.T) {
t.Parallel()
ui := new(cli.MockUi)
cmd := &JobPromoteCommand{Meta: Meta{Ui: ui}}

View File

@ -8,10 +8,12 @@ import (
)
func TestJobRevertCommand_Implements(t *testing.T) {
t.Parallel()
var _ cli.Command = &JobDispatchCommand{}
}
func TestJobRevertCommand_Fails(t *testing.T) {
t.Parallel()
ui := new(cli.MockUi)
cmd := &JobRevertCommand{Meta: Meta{Ui: ui}}

View File

@ -8,6 +8,7 @@ import (
)
func TestKeygenCommand(t *testing.T) {
t.Parallel()
ui := new(cli.MockUi)
c := &KeygenCommand{Meta: Meta{Ui: ui}}
code := c.Run(nil)

View File

@ -8,10 +8,12 @@ import (
)
func TestLogsCommand_Implements(t *testing.T) {
t.Parallel()
var _ cli.Command = &LogsCommand{}
}
func TestLogsCommand_Fails(t *testing.T) {
t.Parallel()
srv, _, url := testServer(t, false, nil)
defer srv.Shutdown()

View File

@ -8,6 +8,7 @@ import (
)
func TestMeta_FlagSet(t *testing.T) {
t.Parallel()
cases := []struct {
Flags FlagSetFlags
Expected []string

View File

@ -11,6 +11,7 @@ import (
)
func TestMonitor_Update_Eval(t *testing.T) {
t.Parallel()
ui := new(cli.MockUi)
mon := newMonitor(ui, nil, fullId)
@ -64,6 +65,7 @@ func TestMonitor_Update_Eval(t *testing.T) {
}
func TestMonitor_Update_Allocs(t *testing.T) {
t.Parallel()
ui := new(cli.MockUi)
mon := newMonitor(ui, nil, fullId)
@ -134,6 +136,7 @@ func TestMonitor_Update_Allocs(t *testing.T) {
}
func TestMonitor_Update_AllocModification(t *testing.T) {
t.Parallel()
ui := new(cli.MockUi)
mon := newMonitor(ui, nil, fullId)
@ -169,6 +172,7 @@ func TestMonitor_Update_AllocModification(t *testing.T) {
}
func TestMonitor_Monitor(t *testing.T) {
t.Parallel()
srv, client, _ := testServer(t, false, nil)
defer srv.Shutdown()
@ -215,6 +219,7 @@ func TestMonitor_Monitor(t *testing.T) {
}
func TestMonitor_MonitorWithPrefix(t *testing.T) {
t.Parallel()
srv, client, _ := testServer(t, false, nil)
defer srv.Shutdown()
@ -283,6 +288,7 @@ func TestMonitor_MonitorWithPrefix(t *testing.T) {
}
func TestMonitor_DumpAllocStatus(t *testing.T) {
t.Parallel()
ui := new(cli.MockUi)
// Create an allocation and dump its status to the UI

View File

@ -8,10 +8,12 @@ import (
)
func TestNodeDrainCommand_Implements(t *testing.T) {
t.Parallel()
var _ cli.Command = &NodeDrainCommand{}
}
func TestNodeDrainCommand_Fails(t *testing.T) {
t.Parallel()
srv, _, url := testServer(t, false, nil)
defer srv.Shutdown()

View File

@ -11,10 +11,12 @@ import (
)
func TestNodeStatusCommand_Implements(t *testing.T) {
t.Parallel()
var _ cli.Command = &NodeStatusCommand{}
}
func TestNodeStatusCommand_Self(t *testing.T) {
t.Parallel()
// Start in dev mode so we get a node registration
srv, client, url := testServer(t, true, func(c *agent.Config) {
c.NodeName = "mynode"
@ -65,6 +67,7 @@ func TestNodeStatusCommand_Self(t *testing.T) {
}
func TestNodeStatusCommand_Run(t *testing.T) {
t.Parallel()
// Start in dev mode so we get a node registration
srv, client, url := testServer(t, true, func(c *agent.Config) {
c.NodeName = "mynode"
@ -159,6 +162,7 @@ func TestNodeStatusCommand_Run(t *testing.T) {
}
func TestNodeStatusCommand_Fails(t *testing.T) {
t.Parallel()
srv, _, url := testServer(t, false, nil)
defer srv.Shutdown()

View File

@ -8,10 +8,12 @@ import (
)
func TestOperator_Raft_ListPeers_Implements(t *testing.T) {
t.Parallel()
var _ cli.Command = &OperatorRaftListCommand{}
}
func TestOperator_Raft_ListPeers(t *testing.T) {
t.Parallel()
s, _, addr := testServer(t, false, nil)
defer s.Shutdown()

View File

@ -8,10 +8,12 @@ import (
)
func TestOperator_Raft_RemovePeers_Implements(t *testing.T) {
t.Parallel()
var _ cli.Command = &OperatorRaftRemoveCommand{}
}
func TestOperator_Raft_RemovePeer(t *testing.T) {
t.Parallel()
s, _, addr := testServer(t, false, nil)
defer s.Shutdown()

View File

@ -7,5 +7,6 @@ import (
)
func TestOperator_Raft_Implements(t *testing.T) {
t.Parallel()
var _ cli.Command = &OperatorRaftCommand{}
}

View File

@ -7,5 +7,6 @@ import (
)
func TestOperator_Implements(t *testing.T) {
t.Parallel()
var _ cli.Command = &OperatorCommand{}
}

View File

@ -12,10 +12,12 @@ import (
)
func TestPlanCommand_Implements(t *testing.T) {
t.Parallel()
var _ cli.Command = &RunCommand{}
}
func TestPlanCommand_Fails(t *testing.T) {
t.Parallel()
ui := new(cli.MockUi)
cmd := &PlanCommand{Meta: Meta{Ui: ui}}
@ -109,6 +111,7 @@ job "job1" {
}
func TestPlanCommand_From_STDIN(t *testing.T) {
t.Parallel()
stdinR, stdinW, err := os.Pipe()
if err != nil {
t.Fatalf("err: %s", err)
@ -151,6 +154,7 @@ job "job1" {
}
func TestPlanCommand_From_URL(t *testing.T) {
t.Parallel()
ui := new(cli.MockUi)
cmd := &PlanCommand{
Meta: Meta{Ui: ui},

View File

@ -12,10 +12,12 @@ import (
)
func TestRunCommand_Implements(t *testing.T) {
t.Parallel()
var _ cli.Command = &RunCommand{}
}
func TestRunCommand_Output_Json(t *testing.T) {
t.Parallel()
ui := new(cli.MockUi)
cmd := &RunCommand{Meta: Meta{Ui: ui}}
@ -51,6 +53,7 @@ job "job1" {
}
func TestRunCommand_Fails(t *testing.T) {
t.Parallel()
ui := new(cli.MockUi)
cmd := &RunCommand{Meta: Meta{Ui: ui}}
@ -154,6 +157,7 @@ job "job1" {
}
func TestRunCommand_From_STDIN(t *testing.T) {
t.Parallel()
stdinR, stdinW, err := os.Pipe()
if err != nil {
t.Fatalf("err: %s", err)
@ -196,6 +200,7 @@ job "job1" {
}
func TestRunCommand_From_URL(t *testing.T) {
t.Parallel()
ui := new(cli.MockUi)
cmd := &RunCommand{
Meta: Meta{Ui: ui},

View File

@ -7,5 +7,6 @@ import (
)
func TestServerForceLeaveCommand_Implements(t *testing.T) {
t.Parallel()
var _ cli.Command = &ServerForceLeaveCommand{}
}

View File

@ -7,5 +7,6 @@ import (
)
func TestServerJoinCommand_Implements(t *testing.T) {
t.Parallel()
var _ cli.Command = &ServerJoinCommand{}
}

View File

@ -8,10 +8,12 @@ import (
)
func TestServerMembersCommand_Implements(t *testing.T) {
t.Parallel()
var _ cli.Command = &ServerMembersCommand{}
}
func TestServerMembersCommand_Run(t *testing.T) {
t.Parallel()
srv, client, url := testServer(t, false, nil)
defer srv.Shutdown()
@ -43,6 +45,7 @@ func TestServerMembersCommand_Run(t *testing.T) {
}
func TestMembersCommand_Fails(t *testing.T) {
t.Parallel()
ui := new(cli.MockUi)
cmd := &ServerMembersCommand{Meta: Meta{Ui: ui}}

View File

@ -9,10 +9,12 @@ import (
)
func TestStatusCommand_Implements(t *testing.T) {
t.Parallel()
var _ cli.Command = &StatusCommand{}
}
func TestStatusCommand_Run(t *testing.T) {
t.Parallel()
srv, client, url := testServer(t, true, nil)
defer srv.Shutdown()
@ -164,6 +166,7 @@ func TestStatusCommand_Run(t *testing.T) {
}
func TestStatusCommand_Fails(t *testing.T) {
t.Parallel()
ui := new(cli.MockUi)
cmd := &StatusCommand{Meta: Meta{Ui: ui}}

View File

@ -8,10 +8,12 @@ import (
)
func TestStopCommand_Implements(t *testing.T) {
t.Parallel()
var _ cli.Command = &StopCommand{}
}
func TestStopCommand_Fails(t *testing.T) {
t.Parallel()
srv, _, url := testServer(t, false, nil)
defer srv.Shutdown()

View File

@ -12,10 +12,12 @@ import (
)
func TestValidateCommand_Implements(t *testing.T) {
t.Parallel()
var _ cli.Command = &ValidateCommand{}
}
func TestValidateCommand(t *testing.T) {
t.Parallel()
ui := new(cli.MockUi)
cmd := &ValidateCommand{Meta: Meta{Ui: ui}}
@ -56,6 +58,7 @@ job "job1" {
}
func TestValidateCommand_Fails(t *testing.T) {
t.Parallel()
ui := new(cli.MockUi)
cmd := &ValidateCommand{Meta: Meta{Ui: ui}}
@ -113,6 +116,7 @@ func TestValidateCommand_Fails(t *testing.T) {
}
func TestValidateCommand_From_STDIN(t *testing.T) {
t.Parallel()
stdinR, stdinW, err := os.Pipe()
if err != nil {
t.Fatalf("err: %s", err)
@ -158,6 +162,7 @@ job "job1" {
}
func TestValidateCommand_From_URL(t *testing.T) {
t.Parallel()
ui := new(cli.MockUi)
cmd := &RunCommand{
Meta: Meta{Ui: ui},

View File

@ -7,5 +7,6 @@ import (
)
func TestVersionCommand_implements(t *testing.T) {
t.Parallel()
var _ cli.Command = &VersionCommand{}
}