Vendor + test fixes

This commit is contained in:
Alex Dadgar
2017-02-22 14:15:22 -08:00
parent 55e7ad7fd9
commit eaa57878d9
18 changed files with 995 additions and 27 deletions

View File

@@ -18,10 +18,10 @@ func TestHTTP_JobsList(t *testing.T) {
httpTest(t, nil, func(s *TestServer) {
for i := 0; i < 3; i++ {
// Create the job
job := api.MockJob()
args := api.JobRegisterRequest{
job := mock.Job()
args := structs.JobRegisterRequest{
Job: job,
WriteRequest: api.WriteRequest{Region: "global"},
WriteRequest: structs.WriteRequest{Region: "global"},
}
var resp structs.JobRegisterResponse
if err := s.Agent.RPC("Job.Register", &args, &resp); err != nil {
@@ -70,12 +70,12 @@ func TestHTTP_PrefixJobsList(t *testing.T) {
httpTest(t, nil, func(s *TestServer) {
for i := 0; i < 3; i++ {
// Create the job
job := api.MockJob()
job.ID = &ids[i]
*job.TaskGroups[0].Count = 1
args := api.JobRegisterRequest{
job := mock.Job()
job.ID = ids[i]
job.TaskGroups[0].Count = 1
args := structs.JobRegisterRequest{
Job: job,
WriteRequest: api.WriteRequest{Region: "global"},
WriteRequest: structs.WriteRequest{Region: "global"},
}
var resp structs.JobRegisterResponse
if err := s.Agent.RPC("Job.Register", &args, &resp); err != nil {

View File

@@ -14,6 +14,7 @@ import (
"github.com/hashicorp/nomad/api"
"github.com/hashicorp/nomad/helper"
"github.com/hashicorp/nomad/helper/flatmap"
"github.com/kr/pretty"
"github.com/mitchellh/cli"
)
@@ -214,8 +215,6 @@ const (
var (
expectedApiJob = &api.Job{
ID: helper.StringToPtr("job1"),
Region: helper.StringToPtr("global"),
Priority: helper.IntToPtr(50),
Name: helper.StringToPtr("job1"),
Type: helper.StringToPtr("service"),
Datacenters: []string{"dc1"},
@@ -228,20 +227,12 @@ var (
Interval: helper.TimeToPtr(15 * time.Second),
Mode: helper.StringToPtr("delay"),
},
EphemeralDisk: &api.EphemeralDisk{
SizeMB: helper.IntToPtr(300),
},
Tasks: []*api.Task{
{
Driver: "exec",
Name: "task1",
Resources: &api.Resources{
CPU: helper.IntToPtr(100),
MemoryMB: helper.IntToPtr(10),
IOPS: helper.IntToPtr(0),
},
LogConfig: api.DefaultLogConfig(),
Driver: "exec",
Name: "task1",
Resources: &api.Resources{},
},
},
},
@@ -290,8 +281,9 @@ func TestJobGetter_HTTPServer(t *testing.T) {
t.Fatalf("err: %s", err)
}
if !reflect.DeepEqual(expectedApiJob, aj) {
eflat := flatmap.Flatten(expectedApiJob, nil, false)
aflat := flatmap.Flatten(aj, nil, false)
t.Fatalf("got:\n%v\nwant:\n%v", aflat, eflat)
for _, d := range pretty.Diff(expectedApiJob, aj) {
t.Logf(d)
}
t.Fatalf("Unexpected file")
}
}

View File

@@ -45,7 +45,7 @@ job "job1" {
if code := cmd.Run([]string{"-output", fh.Name()}); code != 0 {
t.Fatalf("expected exit code 0, got: %d", code)
}
if out := ui.OutputWriter.String(); !strings.Contains(out, `"Region": "global",`) {
if out := ui.OutputWriter.String(); !strings.Contains(out, `"Type": "service",`) {
t.Fatalf("Expected JSON output: %v", out)
}
}