github.com/ryanslade/nomad@v0.2.4-0.20160128061903-fc95782f2089/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  		Require(&Resources{MemoryMB: 256})
    25  
    26  	group := NewTaskGroup("group1", 1).
    27  		AddTask(task)
    28  
    29  	job := NewBatchJob("job1", "redis", "region1", 1).
    30  		AddDatacenter("dc1").
    31  		AddTaskGroup(group)
    32  
    33  	return job
    34  }
    35  
    36  func testPeriodicJob() *Job {
    37  	job := testJob().AddPeriodicConfig(&PeriodicConfig{
    38  		Enabled:  true,
    39  		Spec:     "*/30 * * * *",
    40  		SpecType: "cron",
    41  	})
    42  	return job
    43  }