mirror of
https://github.com/bjdgyc/anylink.git
synced 2025-08-08 12:24:30 +08:00
完善测试文件
This commit is contained in:
33
server/dbdata/group_test.go
Normal file
33
server/dbdata/group_test.go
Normal file
@@ -0,0 +1,33 @@
|
||||
package dbdata
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/bjdgyc/anylink/pkg/utils"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestGetGroupNames(t *testing.T) {
|
||||
ast := assert.New(t)
|
||||
|
||||
preIpData()
|
||||
defer closeIpdata()
|
||||
|
||||
// 添加 group
|
||||
g1 := Group{Name: "g1", ClientDns: []ValData{{Val: "114.114.114.114"}}}
|
||||
err := SetGroup(&g1)
|
||||
ast.Nil(err)
|
||||
g2 := Group{Name: "g2", ClientDns: []ValData{{Val: "114.114.114.114"}}}
|
||||
err = SetGroup(&g2)
|
||||
ast.Nil(err)
|
||||
g3 := Group{Name: "g3", ClientDns: []ValData{{Val: "114.114.114.114"}}}
|
||||
err = SetGroup(&g3)
|
||||
ast.Nil(err)
|
||||
|
||||
// 判断所有数据
|
||||
gAll := []string{"g1", "g2", "g3"}
|
||||
gs := GetGroupNames()
|
||||
for _, v := range gs {
|
||||
ast.Equal(true, utils.InArrStr(gAll, v))
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user