-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathclient_test.go
More file actions
58 lines (44 loc) · 1.49 KB
/
client_test.go
File metadata and controls
58 lines (44 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package goro_test
import (
"net/http"
"net/http/httptest"
"testing"
"github.com/stretchr/testify/assert"
"github.com/vectorhacker/goro"
)
func TestClient(t *testing.T) {
t.Run("it should return a valid client", func(t *testing.T) {
c := goro.Connect("http://localhost:2113")
assert.NotNil(t, c)
})
t.Run("it should return a valid sling.Sling object", func(t *testing.T) {
c := goro.Connect("http://localhost:2113")
assert.NotNil(t, c.Sling())
})
t.Run("it should return a reader", func(t *testing.T) {
c := goro.Connect("http://localhost:2113")
assert.NotNil(t, c.BackwardsReader("tests"))
})
t.Run("it should return a writer", func(t *testing.T) {
c := goro.Connect("http://localhost:2113")
var writer goro.Writer = c.Writer("tests")
assert.NotNil(t, writer)
})
t.Run("it should return a CatchupSubscription", func(t *testing.T) {
c := goro.Connect("http://localhost:2113")
var subscription goro.Subscriber = c.CatchupSubscription("testing", 0)
assert.NotNil(t, subscription)
})
t.Run("it should return a PersistentSubscription", func(t *testing.T) {
mux := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusCreated)
})
s := httptest.NewServer(mux)
c := goro.Connect(s.URL, goro.WithHTTPClient(s.Client()))
var subscription goro.Subscriber
var err error
subscription, err = c.PersistentSubscription("testing", "test", goro.PersistentSubscriptionSettings{})
assert.Nil(t, err)
assert.NotNil(t, subscription)
})
}