Add a wait condition in outgoing webhook test to prevent race condition (#3177)
Этот коммит содержится в:
@@ -136,7 +136,10 @@ func testCreatePostWithOutgoingHook(
|
|||||||
// validate the webhook body fields and write to the success channel on
|
// validate the webhook body fields and write to the success channel on
|
||||||
// success/failure.
|
// success/failure.
|
||||||
success := make(chan bool)
|
success := make(chan bool)
|
||||||
|
wait := make(chan bool, 1)
|
||||||
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
<-wait
|
||||||
|
|
||||||
requestContentType := r.Header.Get("Content-Type")
|
requestContentType := r.Header.Get("Content-Type")
|
||||||
if requestContentType != expectedContentType {
|
if requestContentType != expectedContentType {
|
||||||
t.Logf("Content-Type is %s, should be %s", requestContentType, expectedContentType)
|
t.Logf("Content-Type is %s, should be %s", requestContentType, expectedContentType)
|
||||||
@@ -217,6 +220,8 @@ func testCreatePostWithOutgoingHook(
|
|||||||
post = result.Data.(*model.Post)
|
post = result.Data.(*model.Post)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wait <- true
|
||||||
|
|
||||||
// We wait for the test server to write to the success channel and we make
|
// 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.
|
// the test fail if that doesn't happen before the timeout.
|
||||||
select {
|
select {
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user