add test file
This commit is contained in:
parent
51c3ed0e66
commit
99c61b5af1
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,4 +1,5 @@
|
||||
config.yml
|
||||
.vscode
|
||||
.idea
|
||||
module/schema/static.go*.swp
|
||||
module/schema/static.go
|
12
module/apimsg/apimsg_test.go
Normal file
12
module/apimsg/apimsg_test.go
Normal file
@ -0,0 +1,12 @@
|
||||
package apimsg
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestGetRes(t *testing.T) {
|
||||
res := GetRes("Success", nil)
|
||||
if res.Status != 200 {
|
||||
t.Error("Status Code not match")
|
||||
}
|
||||
}
|
25
module/utils/utils_test.go
Normal file
25
module/utils/utils_test.go
Normal file
@ -0,0 +1,25 @@
|
||||
package utils
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestCalcPage(t *testing.T) {
|
||||
page := CalcPage(10, 1, 10)
|
||||
if page.Page != 1 {
|
||||
t.Error("Page Calc fail")
|
||||
}
|
||||
if page.Total != 1 {
|
||||
t.Error("Page Calc fail")
|
||||
}
|
||||
if page.Limit != 10 {
|
||||
t.Error("limit calc fail")
|
||||
}
|
||||
if page.Offset != 0 {
|
||||
t.Error("offset calc fail")
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkCalcPage(b *testing.B) {
|
||||
for i := 0; i < b.N; i++ {
|
||||
CalcPage(10000, 30, 10)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user