github.com/dkerwin/nomad@v0.3.3-0.20160525181927-74554135514b/api/util_test.go (about) 1 package api 2 3 import ( 4 "testing" 5 ) 6 7 func assertQueryMeta(t *testing.T, qm *QueryMeta) { 8 if qm.LastIndex == 0 { 9 t.Fatalf("bad index: %d", qm.LastIndex) 10 } 11 if !qm.KnownLeader { 12 t.Fatalf("expected known leader, got none") 13 } 14 } 15 16 func assertWriteMeta(t *testing.T, wm *WriteMeta) { 17 if wm.LastIndex == 0 { 18 t.Fatalf("bad index: %d", wm.LastIndex) 19 } 20 } 21 22 func testJob() *Job { 23 task := NewTask("task1", "exec"). 24 SetConfig("command", "/bin/sleep"). 25 Require(&Resources{ 26 CPU: 100, 27 MemoryMB: 256, 28 DiskMB: 25, 29 IOPS: 10, 30 }). 31 SetLogConfig(&LogConfig{ 32 MaxFiles: 1, 33 MaxFileSizeMB: 2, 34 }) 35 36 group := NewTaskGroup("group1", 1). 37 AddTask(task) 38 39 job := NewBatchJob("job1", "redis", "region1", 1). 40 AddDatacenter("dc1"). 41 AddTaskGroup(group) 42 43 return job 44 } 45 46 func testPeriodicJob() *Job { 47 job := testJob().AddPeriodicConfig(&PeriodicConfig{ 48 Enabled: true, 49 Spec: "*/30 * * * *", 50 SpecType: "cron", 51 }) 52 return job 53 }