6 "github.com/stretchr/testify/assert"
9 func TestWaitingTaskDisplaysWaitingStatus(t *testing.T) {
10 task := NewWaitingTask("example")
12 assert.Equal(t, "example: ...", (<-task.Updates()).S)
15 func TestWaitingTaskCallsDoneWhenComplete(t *testing.T) {
16 task := NewWaitingTask("example")
19 case v, ok := <-task.Updates():
21 assert.Equal(t, "example: ...", v.S)
23 t.Fatal("expected channel to be open")
30 if _, ok := <-task.Updates(); ok {
31 t.Fatalf("expected channel to be closed")
35 func TestWaitingTaskPanicsWithMultipleDoneCalls(t *testing.T) {
36 task := NewWaitingTask("example")
41 if err := recover(); err == nil {
42 t.Fatal("tasklog: expected panic()")
44 if s, ok := err.(error); ok {
45 assert.Equal(t, "close of closed channel", s.Error())
47 t.Fatal("tasklog: expected panic() to implement error")
55 func TestWaitingTaskIsThrottled(t *testing.T) {
56 task := NewWaitingTask("example")
58 throttled := task.Throttled()
60 assert.True(t, throttled,
61 "tasklog: expected *WaitingTask to be Throttle()-d")