-
Notifications
You must be signed in to change notification settings - Fork 0
/
api_test.go
33 lines (30 loc) · 884 Bytes
/
api_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
package main
import (
"github.com/stretchr/testify/assert"
"testing"
)
func TestApiServer_ConnectClient(t *testing.T) {
id := ClientId("127.0.0.2-1")
var d = &Device{
Id: "",
Type: "",
Index: 0,
ConnectedClients: make(map[ClientId]*ConnectedClient),
}
d.ConnectClient(id)
assert.Equal(t, true, d.IsConnected(id), "they should be equal")
assert.Equal(t, false, d.IsConnected("127.0.0.1-1"), "they should be equal")
}
func TestApiServer_DisconnectClient(t *testing.T) {
id := ClientId("127.0.0.2-1")
var d = &Device{
Id: "",
Type: "",
Index: 0,
ConnectedClients: make(map[ClientId]*ConnectedClient),
}
d.ConnectClient(id)
assert.Equal(t, true, d.IsConnected(id), "they should be equal")
d.DisconnectClient(id)
assert.Equal(t, false, d.IsConnected(id), "they should be equal")
}