forked from notrustverify/nymsocketmanager
-
Notifications
You must be signed in to change notification settings - Fork 0
/
nymSocketManager_test.go
57 lines (39 loc) · 1.44 KB
/
nymSocketManager_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
package nymsocketmanager_test
import (
"testing"
lib "github.com/notrustverify/nymsocketmanager"
"github.com/rs/zerolog"
"github.com/stretchr/testify/require"
)
func emptyProcessing(lib.NymReceived, func(lib.NymMessage) error) {}
func TestNymSocketManagerShouldHaveANonEmptyConnectionURI(t *testing.T) {
logger := zerolog.Logger{}
_, e := lib.NewNymSocketManager("", emptyProcessing, &logger)
require.Error(t, e)
}
func TestNymSocketManagerShouldHaveAValidProcessingFunction(t *testing.T) {
logger := zerolog.Logger{}
_, e := lib.NewNymSocketManager("ws://127.0.0.1", nil, &logger)
require.Error(t, e)
}
func TestNymSocketManagerShouldHaveAValidLogger(t *testing.T) {
_, e := lib.NewNymSocketManager("ws://127.0.0.1", emptyProcessing, nil)
require.Error(t, e)
}
func TestNymSocketManagerShouldNotStartWithWrongClientIDWS(t *testing.T) {
logger := zerolog.Logger{}
nymSocketManager, e := lib.NewNymSocketManager("aaaaaaaaaaaa", emptyProcessing, &logger)
require.NoError(t, e)
_, e = nymSocketManager.Start()
require.Error(t, e)
}
func TestNymSocketManagerGetGateway(t *testing.T) {
logger := zerolog.Logger{}
nymSocketManager, e := lib.NewNymSocketManager("ws://127.0.0.1:10977", func(_ lib.NymReceived, _ func(lib.NymMessage) error) {}, &logger)
require.NoError(t, e)
_, e = nymSocketManager.Start()
require.NoError(t, e)
nymSocketManager.Stop()
gatewayAddr := nymSocketManager.GetConnectedGateway()
require.NotEmpty(t, gatewayAddr)
}