Skip to content

Commit

Permalink
Merge pull request moby#11842 from brahmaroutu/events_tests
Browse files Browse the repository at this point in the history
Events tests
  • Loading branch information
LK4D4 committed Mar 27, 2015
2 parents 121de9e + f5ad895 commit 8c58bdd
Showing 1 changed file with 21 additions and 40 deletions.
61 changes: 21 additions & 40 deletions integration-cli/docker_cli_events_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,26 +317,7 @@ func TestEventsFilterContainerID(t *testing.T) {
t.Fatalf("Failed to get events, error: %s(%s)", err, out)
}
events := strings.Split(out, "\n")
events = events[:len(events)-1]
if len(events) == 0 || len(events) > 3 {
t.Fatalf("Expected 3 events, got %d: %v", len(events), events)
}
createEvent := strings.Fields(events[0])
if createEvent[len(createEvent)-1] != "create" {
t.Fatalf("first event should be create, not %#v", createEvent)
}
if len(events) > 1 {
startEvent := strings.Fields(events[1])
if startEvent[len(startEvent)-1] != "start" {
t.Fatalf("second event should be start, not %#v", startEvent)
}
}
if len(events) == 3 {
dieEvent := strings.Fields(events[len(events)-1])
if dieEvent[len(dieEvent)-1] != "die" {
t.Fatalf("event should be die, not %#v", dieEvent)
}
}
checkEvents(t, events[:len(events)-1])
}

logDone("events - filters using container id")
Expand All @@ -363,27 +344,27 @@ func TestEventsFilterContainerName(t *testing.T) {
t.Fatalf("Failed to get events, error : %s(%s)", err, out)
}
events := strings.Split(out, "\n")
events = events[:len(events)-1]
if len(events) == 0 || len(events) > 3 {
t.Fatalf("Expected 3 events, got %d: %v", len(events), events)
}
createEvent := strings.Fields(events[0])
if createEvent[len(createEvent)-1] != "create" {
t.Fatalf("first event should be create, not %#v", createEvent)
}
if len(events) > 1 {
startEvent := strings.Fields(events[1])
if startEvent[len(startEvent)-1] != "start" {
t.Fatalf("second event should be start, not %#v", startEvent)
}
}
if len(events) == 3 {
dieEvent := strings.Fields(events[len(events)-1])
if dieEvent[len(dieEvent)-1] != "die" {
t.Fatalf("event should be die, not %#v", dieEvent)
}
}
checkEvents(t, events[:len(events)-1])
}

logDone("events - filters using container name")
}

func checkEvents(t *testing.T, events []string) {
if len(events) != 3 {
t.Fatalf("Expected 3 events, got %d: %v", len(events), events)
}
createEvent := strings.Fields(events[0])
if createEvent[len(createEvent)-1] != "create" {
t.Fatalf("first event should be create, not %#v", createEvent)
}
startEvent := strings.Fields(events[1])
if startEvent[len(startEvent)-1] != "start" {
t.Fatalf("second event should be start, not %#v", startEvent)
}
dieEvent := strings.Fields(events[len(events)-1])
if dieEvent[len(dieEvent)-1] != "die" {
t.Fatalf("event should be die, not %#v", dieEvent)
}

}

0 comments on commit 8c58bdd

Please sign in to comment.