Skip to content

Commit

Permalink
Use a latch channel
Browse files Browse the repository at this point in the history
  • Loading branch information
evanphx committed May 1, 2015
1 parent 2a89139 commit 9e412b8
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions plugins/elasticsearch/send_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"net"
"net/http"
"testing"
"time"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
Expand All @@ -25,6 +24,8 @@ func TestSend(t *testing.T) {
url string
)

c := make(chan bool, 1)

serv := http.Server{
Addr: ":0",
Handler: http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
Expand All @@ -35,6 +36,8 @@ func TestSend(t *testing.T) {
req.Body.Close()

res.WriteHeader(200)

c <- true
}),
}

Expand All @@ -60,7 +63,7 @@ func TestSend(t *testing.T) {
err = es.Receive(m)
require.NoError(t, err)

time.Sleep(100 * time.Millisecond)
<-c

err = es.Close()
require.NoError(t, err)
Expand Down

0 comments on commit 9e412b8

Please sign in to comment.