-
Notifications
You must be signed in to change notification settings - Fork 0
/
database_test.go
53 lines (49 loc) · 1.32 KB
/
database_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
package hansip
// func TestShutdown(t *testing.T) {
// connTickDelay = 1 * time.Millisecond
// csTickDelay = 1 * time.Millisecond
// masterClosed := false
// masterConn := &connection{
// connected: true,
// host: "master",
// quitCh: make(chan bool),
// s: &dummySQL{},
// pingFn: func() error {
// return nil
// },
// closeFn: func() {
// masterClosed = true
// },
// }
// go masterConn.loop()
// slaveClosed := false
// slaveConns := []*connection{
// &connection{
// connected: true,
// host: "slave1",
// quitCh: make(chan bool),
// s: &dummySQL{},
// pingFn: func() error {
// return nil
// },
// closeFn: func() {
// slaveClosed = true
// },
// },
// }
// go slaveConns[0].loop()
// cs = &connectionSet{
// masterConn: masterConn,
// slaveConns: slaveConns,
// asMutex: new(sync.RWMutex),
// quitCh: make(chan bool),
// }
// go cs.loop()
// time.Sleep(5 * time.Millisecond)
// Shutdown()
// time.Sleep(5 * time.Millisecond)
// assert.True(t, masterClosed, "fail to run closeFn on master")
// assert.True(t, slaveClosed, "fail to run closeFn connection on slave")
// assert.False(t, masterConn.connected, "fail to close master")
// assert.False(t, slaveConns[0].connected, "fail to close slave connections")
// }