-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain_test.go
106 lines (94 loc) · 2.07 KB
/
main_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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
package main
import (
"testing"
. "github.com/smartystreets/goconvey/convey"
"github.com/tiltfactor/toto/domain"
)
type testComm struct {
ID string
}
func (t testComm) Id() string {
return t.ID
}
func (t testComm) Rooms() []string {
return []string{}
}
func (t testComm) On(event string, f interface{}) error {
return nil
}
func (t testComm) Emit(event string, args ...interface{}) error {
return nil
}
func (t testComm) Join(room string) error {
return nil
}
func (t testComm) Leave(room string) error {
return nil
}
func (t testComm) BroadcastTo(room, event string, args ...interface{}) error {
return nil
}
func TestQueuePlayers(t *testing.T) {
Convey("Players should be added to the queue", t, func() {
Convey("When they are not already in the queue", func() {
g := domain.Game{
Lobby: domain.NewLobby(),
}
p := domain.Player{
Comm: testComm{
ID: "testID",
},
}
So(QueuePlayers(g, p), ShouldBeTrue)
})
Convey("But not when they are already in the queue", func() {
g := domain.Game{
Lobby: domain.NewLobby(),
}
p := domain.Player{
Comm: testComm{
ID: "testID",
},
}
QueuePlayers(g, p)
So(QueuePlayers(g, p), ShouldBeFalse)
})
})
}
//
// func TestGroupPlayers(t *testing.T) {
// Convey("Players should be grouped", t, func() {
// Convey("When the min number of players is available", func() {
// g := domain.Game{
// MinPlayers: 2
// Lobby: domain.NewLobby(),
// }
// p := domain.Player{
// Comm: testComm{
// ID: "testID",
// },
// }
// p2 := domain.Player{
// Comm: testComm{
// ID: "testID2",
// },
// }
// QueuePlayers(g, p)
// QueuePlayers(g, p2)
// So(GroupPlayers(g, gi *GamesInfo))
// So(QueuePlayers(g, p), ShouldBeTrue)
// })
// Convey("But not when they are already in the queue", func() {
// g := domain.Game{
// Lobby: domain.NewLobby(),
// }
// p := domain.Player{
// Comm: testComm{
// ID: "testID",
// },
// }
// QueuePlayers(g, p)
// So(QueuePlayers(g, p), ShouldBeFalse)
// })
// })
// }