Skip to content

Commit

Permalink
Added the test case for distribworks#131 (distribworks#135)
Browse files Browse the repository at this point in the history
Can't reproduce
  • Loading branch information
Victor Castell committed Jun 1, 2016
1 parent 1ecebb3 commit 517441a
Showing 1 changed file with 6 additions and 20 deletions.
26 changes: 6 additions & 20 deletions dkron/agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,33 +218,19 @@ func Test_processFilteredNodes(t *testing.T) {
job := &Job{
Name: "test_job_1",
Tags: map[string]string{
"foo": "bar:1",
"role": "test:2",
},
}

time.Sleep(2 * time.Second)
nodes, tags, err := a.processFilteredNodes(job)

if nodes[0] != "test1" || nodes[1] != "test2" {
t.Fatal("Not expected returned nodes")
}

if tags["role"] != "test" {
t.Fatalf("Tags error, expected: test, got %s", tags["role"])
}

if job.Tags["role"] != "test:2" {
t.Fatalf("Job tags error, expected: 'role=test:2', got 'role=%s'", job.Tags["role"])
}

job = &Job{
Name: "test_job_1",
Tags: map[string]string{
"role": "test",
},
}

nodes, tags, err = a.processFilteredNodes(job)
assert.Equal(t, nodes[0], "test1")
assert.Equal(t, nodes[1], "test2")
assert.Equal(t, tags["role"], "test")
assert.Equal(t, job.Tags["role"], "test:2")
assert.Equal(t, job.Tags["foo"], "bar:1")

// Send a shutdown request
shutdownCh <- struct{}{}
Expand Down

0 comments on commit 517441a

Please sign in to comment.