...
1 package entrypoint
2
3 import (
4 "net/http"
5 "net/http/httptest"
6 "testing"
7
8 "github.com/stretchr/testify/assert"
9
10 "github.com/datawire/dlib/dlog"
11 )
12
13
14 func TestNotifyWebhookUrlConnectionRefused(t *testing.T) {
15 ctx := dlog.NewTestContext(t, false)
16
17 finished, err := notifyWebhookUrl(ctx, "test", "http://localhost:5555")
18 assert.NoError(t, err)
19 assert.False(t, finished)
20 }
21
22
23 func TestNotifyWebhookUrlEOF(t *testing.T) {
24 ctx := dlog.NewTestContext(t, false)
25
26 var srv *httptest.Server
27 srv = httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
28
29 srv.CloseClientConnections()
30 }))
31
32 _, err := notifyWebhookUrl(ctx, "test", srv.URL)
33 assert.Error(t, err)
34 }
35
View as plain text