From 944bebf99dc65fb2afff0ea961a55392f23b35b8 Mon Sep 17 00:00:00 2001 From: Robert Jacob Date: Thu, 23 Jun 2016 01:25:55 +0200 Subject: [PATCH] Wait for goroutine in Delete test. --- api/service_test.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/api/service_test.go b/api/service_test.go index 3531fe2..414dc56 100644 --- a/api/service_test.go +++ b/api/service_test.go @@ -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) @@ -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 } }