Skip to content

Commit

Permalink
simplify test
Browse files Browse the repository at this point in the history
  • Loading branch information
umputun committed May 30, 2019
1 parent 722c754 commit b72aeaa
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
6 changes: 3 additions & 3 deletions app/agent/demo_mode_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ import (
func TestDemoEmitter_Logs(t *testing.T) {
d := DemoEmitter{time.Millisecond * 100}
wr := mockDemoWriter{}
ctx, cancel := context.WithCancel(context.Background())
time.AfterFunc(time.Millisecond*1090, cancel)
ctx, cancel := context.WithTimeout(context.Background(), time.Millisecond*1090)
defer cancel()
err := d.Logs(docker.LogsOptions{Context: ctx, OutputStream: &wr})
assert.EqualError(t, err, "context canceled")
assert.EqualError(t, err, "context deadline exceeded")
t.Logf("%+v", wr.Get())
assert.Equal(t, 10+1, len(wr.Get()), "10 messages with extra \n")
}
Expand Down
4 changes: 1 addition & 3 deletions app/agent/docker_logger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ func TestLogger_WithError(t *testing.T) {
assert.EqualError(t, e, "context canceled", e.Error())
}()
time.Sleep(10 * time.Millisecond)
time.AfterFunc(time.Second, func() {
cancel()
})
time.AfterFunc(time.Second, cancel)
l.Wait()
assert.True(t, time.Since(st) < time.Second*2, "terminated early")
time.Sleep(10 * time.Millisecond)
Expand Down

0 comments on commit b72aeaa

Please sign in to comment.