-
Notifications
You must be signed in to change notification settings - Fork 9
/
store_test.go
46 lines (35 loc) · 1.19 KB
/
store_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
package bifrost_test
import (
"testing"
"github.com/DE-labtory/bifrost"
"github.com/DE-labtory/bifrost/mocks"
"github.com/stretchr/testify/assert"
)
func TestConnectionStore_AddConnection(t *testing.T) {
testConnStroe := bifrost.NewConnectionStore()
testConn, err := mocks.NewMockConnection("127.0.0.1:1234")
assert.NoError(t, err)
err = testConnStroe.AddConnection(testConn)
assert.NoError(t, err)
}
func TestConnectionStore_DeleteConnection(t *testing.T) {
testConnStore := bifrost.NewConnectionStore()
testConn, err := mocks.NewMockConnection("127.0.0.1:1234")
assert.NoError(t, err)
err = testConnStore.AddConnection(testConn)
assert.NoError(t, err)
err = testConnStore.DeleteConnection("wrong ID")
assert.Error(t, err)
err = testConnStore.DeleteConnection(testConn.GetID())
assert.NoError(t, err)
}
func TestConnectionStore_GetConnection(t *testing.T) {
testConnStore := bifrost.NewConnectionStore()
testConn, err := mocks.NewMockConnection("127.0.0.1:1234")
assert.NoError(t, err)
err = testConnStore.AddConnection(testConn)
assert.NoError(t, err)
loadedConn, err := testConnStore.GetConnection(testConn.GetID())
assert.NoError(t, err)
assert.Equal(t, testConn, loadedConn)
}