forked from ngaut/sqltop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
stat_test.go
54 lines (43 loc) · 982 Bytes
/
stat_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
package main
import (
"testing"
"github.com/stretchr/testify/suite"
)
type StatTestSuite struct {
suite.Suite
}
func (suite *StatTestSuite) SetupTest() {
// FIXME: hard-coded test env
cfg = &Conf{
Host: "127.0.01",
Port: 4001,
DBUser: "root",
DBPwd: "",
NumProcessToShow: 10,
}
InitDB()
}
func (suite *StatTestSuite) TestRefreshProcessList() {
err := refreshProcessList()
suite.Nil(err)
processList, ok := Stat().Load(PROCESS_LIST)
suite.Equal(true, ok)
suite.Greater(len(processList.([]ProcessRecord)), 0)
usingDBs, ok := Stat().Load(USING_DBS)
suite.Equal(true, ok)
suite.Greater(usingDBs.(int), 0)
}
/* TODO
func (suite *StatTestSuite) TestIOStat() {
err := refreshIOStat()
suite.Nil(err)
if list, ok := Stat().Load(TABLES_IO_STATUS); ok {
for _, r := range list.([]TableRegionStatus) {
fmt.Println(r)
}
}
}
*/
func TestSuiteTestSuite(t *testing.T) {
suite.Run(t, new(StatTestSuite))
}