Skip to content

Commit

Permalink
Wait for goroutine in Delete test.
Browse files Browse the repository at this point in the history
  • Loading branch information
xperimental committed Jun 22, 2016
1 parent 88b37a3 commit 944bebf
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions api/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,12 +256,16 @@ func TestServiceDelete(t *testing.T) {
params := make(map[string]string)
params["_1"] = test.path

join := make(chan bool)
go func() {
id := <-store.deleteChan
if id != test.expected {
t.Errorf("got '%s', wanted '%s'", id, test.expected)
if len(test.expected) > 0 {
id := <-store.deleteChan
if id != test.expected {
t.Errorf("got '%s', wanted '%s'", id, test.expected)
}
store.deleteResultChan <- test.err
}
store.deleteResultChan <- test.err
join <- true
}()

s.Delete(params, w, r)
Expand All @@ -273,5 +277,6 @@ func TestServiceDelete(t *testing.T) {
if w.Body.String() != test.output {
t.Errorf("got '%s', wanted '%s'", w.Body.String(), test.output)
}
<-join
}
}

0 comments on commit 944bebf

Please sign in to comment.