-
-
Notifications
You must be signed in to change notification settings - Fork 49
/
client_test.go
37 lines (31 loc) · 849 Bytes
/
client_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
package neffos_test
import (
"context"
"fmt"
"github.com/kataras/neffos"
gobwas "github.com/kataras/neffos/gobwas"
gorilla "github.com/kataras/neffos/gorilla"
)
func runTestClient(addr string, connHandler neffos.ConnHandler, testFn func(string, *neffos.Client)) func() error {
gobwasClient, err := neffos.Dial(context.TODO(), gobwas.DefaultDialer, fmt.Sprintf("ws://%s/gobwas", addr), connHandler)
if err != nil {
return func() error {
return err
}
}
gorillaClient, err := neffos.Dial(context.TODO(), gorilla.DefaultDialer, fmt.Sprintf("ws://%s/gorilla", addr), connHandler)
if err != nil {
return func() error {
return err
}
}
// teardown.
teardown := func() error {
gobwasClient.Close()
gorillaClient.Close()
return nil
}
testFn("gobwas", gobwasClient)
testFn("gorilla", gorillaClient)
return teardown
}