Skip to content

Commit

Permalink
Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dadgar committed Feb 2, 2016
1 parent 95e6a62 commit 7ea6619
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
6 changes: 5 additions & 1 deletion command/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions nomad/mock/mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ func Job() *structs.Job {
Resources: &structs.Resources{
CPU: 500,
MemoryMB: 256,
DiskMB: 100,
Networks: []*structs.NetworkResource{
&structs.NetworkResource{
MBits: 50,
Expand Down
3 changes: 1 addition & 2 deletions nomad/structs/structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
11 changes: 8 additions & 3 deletions nomad/structs/structs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 7ea6619

Please sign in to comment.