summaryrefslogtreecommitdiffstats
path: root/api/post_test.go
diff options
context:
space:
mode:
authorJoram Wilander <jwawilander@gmail.com>2016-05-31 12:56:15 -0400
committerJoram Wilander <jwawilander@gmail.com>2016-05-31 12:56:15 -0400
commit8563fbc41ef2d18d4067928cc82f53f745cae446 (patch)
tree4d1c4c0b164c2f756ad275f326692fe5651e5dff /api/post_test.go
parente23084ba1debc37686abc46789b20ab813151474 (diff)
downloadchat-8563fbc41ef2d18d4067928cc82f53f745cae446.tar.gz
chat-8563fbc41ef2d18d4067928cc82f53f745cae446.tar.bz2
chat-8563fbc41ef2d18d4067928cc82f53f745cae446.zip
Add a wait condition in outgoing webhook test to prevent race condition (#3177)
Diffstat (limited to 'api/post_test.go')
-rw-r--r--api/post_test.go5
1 files changed, 5 insertions, 0 deletions
diff --git a/api/post_test.go b/api/post_test.go
index 8a07cdb59..29fe63ddc 100644
--- a/api/post_test.go
+++ b/api/post_test.go
@@ -136,7 +136,10 @@ func testCreatePostWithOutgoingHook(
// validate the webhook body fields and write to the success channel on
// success/failure.
success := make(chan bool)
+ wait := make(chan bool, 1)
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ <-wait
+
requestContentType := r.Header.Get("Content-Type")
if requestContentType != expectedContentType {
t.Logf("Content-Type is %s, should be %s", requestContentType, expectedContentType)
@@ -217,6 +220,8 @@ func testCreatePostWithOutgoingHook(
post = result.Data.(*model.Post)
}
+ wait <- true
+
// We wait for the test server to write to the success channel and we make
// the test fail if that doesn't happen before the timeout.
select {