-
Notifications
You must be signed in to change notification settings - Fork 45
/
transporter_builder_test.go
78 lines (68 loc) · 1.62 KB
/
transporter_builder_test.go
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package rsocket_test
import (
"context"
"crypto/tls"
"fmt"
"net/http"
"os"
"strings"
"testing"
"github.com/google/uuid"
"github.com/rsocket/rsocket-go"
"github.com/stretchr/testify/assert"
)
var fakeSockFile string
var fakeTlsConfig = &tls.Config{
InsecureSkipVerify: true,
}
func init() {
fakeSockFile = fmt.Sprintf("%s/test-rsocket-%s.sock", strings.TrimRight(os.TempDir(), "/"), uuid.New().String())
}
func TestUnixServer(t *testing.T) {
defer os.Remove(fakeSockFile)
u := rsocket.UnixServer().SetPath(fakeSockFile).Build()
assert.NotNil(t, u)
_, err := u(context.Background())
assert.NoError(t, err)
}
func TestUnixClient(t *testing.T) {
assert.NotPanics(t, func() {
rsocket.UnixClient().SetPath(fakeSockFile).Build()
})
}
func TestTcpClient(t *testing.T) {
assert.NotPanics(t, func() {
rsocket.TCPClient().
SetAddr(":7878").
SetHostAndPort("127.0.0.1", 7878).
SetTLSConfig(fakeTlsConfig).
Build()
})
}
func TestTcpServerBuilder(t *testing.T) {
assert.NotPanics(t, func() {
rsocket.TCPServer().SetAddr(":7878").Build()
rsocket.TCPServer().SetHostAndPort("127.0.0.1", 7878).SetTLSConfig(fakeTlsConfig).Build()
})
}
func TestWebsocketClient(t *testing.T) {
assert.NotPanics(t, func() {
h := make(http.Header)
h.Set("x-foo-bar", "qux")
rsocket.WebsocketClient().
SetURL("ws://127.0.0.1:8080/fake/path").
SetHeader(h).
SetTLSConfig(fakeTlsConfig).
Build()
})
}
func TestWebsocketServer(t *testing.T) {
assert.NotPanics(t, func() {
tp := rsocket.WebsocketServer().
SetAddr(":7878").
SetPath("/fake").
SetTLSConfig(fakeTlsConfig).
Build()
assert.NotNil(t, tp)
})
}