command: fix tests after job validation

This commit is contained in:
Ryan Uber
2015-09-16 11:42:28 -07:00
parent 24cd105200
commit da35ecc4f3
2 changed files with 16 additions and 3 deletions

View File

@@ -4,7 +4,6 @@ import (
"strings"
"testing"
"github.com/hashicorp/nomad/api"
"github.com/mitchellh/cli"
)
@@ -32,11 +31,11 @@ func TestStatusCommand_Run(t *testing.T) {
}
// Register two jobs
job1 := api.NewBatchJob("job1", "myjob", 1)
job1 := testJob("job1")
if _, _, err := client.Jobs().Register(job1, nil); err != nil {
t.Fatalf("err: %s", err)
}
job2 := api.NewBatchJob("job2", "myjob", 1)
job2 := testJob("job2")
if _, _, err := client.Jobs().Register(job2, nil); err != nil {
t.Fatalf("err: %s", err)
}

View File

@@ -37,3 +37,17 @@ func testServer(
}
return srv, client, clientConf.Address
}
func testJob(jobID string) *api.Job {
task := api.NewTask("task1", "exec").
Require(&api.Resources{MemoryMB: 256})
group := api.NewTaskGroup("group1", 1).
AddTask(task)
job := api.NewBatchJob(jobID, jobID, "region1", 1).
AddDatacenter("dc1").
AddTaskGroup(group)
return job
}