-
Notifications
You must be signed in to change notification settings - Fork 1
/
store_room_test.go
75 lines (62 loc) · 1.16 KB
/
store_room_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
package main
import (
"log"
"testing"
)
func TestRoomStoreDB(t *testing.T) {
LoadEnviromentVariables()
myContext := newMyContext()
roomDB, err := myContext.RoomStore.Create(RoomDB{
Name: "TestRoom1",
OwnerID: 2,
})
if err != nil {
log.Println(err)
t.Fail()
}
room, err := myContext.RoomStore.GetByID(roomDB.ID)
if err != nil {
log.Println(err)
t.Fail()
}
err = myContext.RoomStore.Delete(room.ID)
if err != nil {
log.Println(err)
t.Fail()
}
_, err = myContext.RoomStore.GetByID(room.ID)
if err == nil {
log.Println("Room cannot deleted")
t.Fail()
}
}
func TestRoomStoreDBListRoomsByUser(t *testing.T) {
LoadEnviromentVariables()
myContext := newMyContext()
userId := 2
_, err := myContext.RoomStore.Create(RoomDB{
Name: "TestRoom1",
OwnerID: userId,
})
if err != nil {
log.Println(err)
t.Fail()
}
_, err = myContext.RoomStore.Create(RoomDB{
Name: "TestRoom2",
OwnerID: 2,
})
if err != nil {
log.Println(err)
t.Fail()
}
rooms, err := myContext.RoomStore.GetByUserID(userId)
if err != nil {
log.Println(err)
t.Fail()
}
if len(rooms) != 2 {
log.Println("Rooms lenght is not match")
t.Fail()
}
}