-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathhealth_test.go
34 lines (29 loc) · 933 Bytes
/
health_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
package balancer
import (
"errors"
"testing"
. "github.com/smartystreets/goconvey/convey"
)
func TestHealthAttributes(t *testing.T) {
Convey("When a valid health is given", t, func() {
expectedErr := errors.New("fail")
health := ServerHealth{
err: expectedErr,
openConnections: &[]int{1}[0],
runningConnections: &[]int{2}[0],
secondsBehindMaster: &[]int{3}[0],
wsrepLocalState: &[]int{4}[0],
ioRunning: true,
wsrepReady: true,
}
Convey("It should return correct values", func() {
So(health.GetErr(), ShouldEqual, expectedErr)
So(*health.GetOpenConnections(), ShouldEqual, 1)
So(*health.GetRunningConnections(), ShouldEqual, 2)
So(*health.GetSecondsBehindMaster(), ShouldEqual, 3)
So(*health.GetWriteSetReplicationState(), ShouldEqual, 4)
So(health.IORunning(), ShouldBeTrue)
So(health.GetWriteSetReady(), ShouldBeTrue)
})
})
}