Tests
This commit is contained in:
parent
f83b26029e
commit
4748bfd869
|
@ -40,7 +40,11 @@ func testServer(
|
|||
|
||||
func testJob(jobID string) *api.Job {
|
||||
task := api.NewTask("task1", "exec").
|
||||
Require(&api.Resources{MemoryMB: 256})
|
||||
Require(&api.Resources{
|
||||
MemoryMB: 256,
|
||||
DiskMB: 20,
|
||||
CPU: 100,
|
||||
})
|
||||
|
||||
group := api.NewTaskGroup("group1", 1).
|
||||
AddTask(task)
|
||||
|
|
|
@ -106,6 +106,7 @@ func Job() *structs.Job {
|
|||
Resources: &structs.Resources{
|
||||
CPU: 500,
|
||||
MemoryMB: 256,
|
||||
DiskMB: 100,
|
||||
Networks: []*structs.NetworkResource{
|
||||
&structs.NetworkResource{
|
||||
MBits: 50,
|
||||
|
|
|
@ -1616,8 +1616,7 @@ func (t *Task) Validate() error {
|
|||
// Validate the resources.
|
||||
if t.Resources == nil {
|
||||
mErr.Errors = append(mErr.Errors, errors.New("Missing task resources"))
|
||||
}
|
||||
if err := t.Resources.MeetsMinResources(); err != nil {
|
||||
} else if err := t.Resources.MeetsMinResources(); err != nil {
|
||||
mErr.Errors = append(mErr.Errors, err)
|
||||
}
|
||||
|
||||
|
|
|
@ -252,9 +252,14 @@ func TestTask_Validate(t *testing.T) {
|
|||
}
|
||||
|
||||
task = &Task{
|
||||
Name: "web",
|
||||
Driver: "docker",
|
||||
Resources: &Resources{},
|
||||
Name: "web",
|
||||
Driver: "docker",
|
||||
Resources: &Resources{
|
||||
CPU: 100,
|
||||
DiskMB: 100,
|
||||
MemoryMB: 100,
|
||||
IOPS: 10,
|
||||
},
|
||||
}
|
||||
err = task.Validate()
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in New Issue