-
Notifications
You must be signed in to change notification settings - Fork 1
/
main_test.go
52 lines (48 loc) · 1.5 KB
/
main_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
package main
import (
"log"
"testing"
"github.com/GoAdminGroup/example/tables"
"github.com/GoAdminGroup/go-admin/modules/config"
"github.com/GoAdminGroup/go-admin/tests"
"github.com/GoAdminGroup/go-admin/tests/common"
"github.com/GoAdminGroup/go-admin/tests/frameworks/gin"
"github.com/GoAdminGroup/go-admin/tests/web"
"github.com/gavv/httpexpect"
)
// Black box testing
func TestExampleBlackBox(t *testing.T) {
tests.BlackBoxTestSuit(t, gin.NewHandler, config.DatabaseList{
"default": config.Database{
File: "./admin_test.db",
Driver: "sqlite",
},
}, tables.Generators, func(cfg config.DatabaseList) {
// Data cleaner of the framework
tests.Cleaner(cfg)
// Clean your own data:
// ...
}, func(e *httpexpect.Expect) {
// Test cases of the framework
common.Test(e)
// Write your own API test, for example:
// More usages: https://github.com/gavv/httpexpect
// e.POST("/signin").Expect().Status(http.StatusOK)
})
}
// User acceptance testing
func TestExampleUserAcceptance(t *testing.T) {
web.UserAcceptanceTestSuit(t, func(t *testing.T, page *web.Page) {
// Write test case base on chromedriver, for example:
// More usages: https://github.com/sclevine/agouti
page.NavigateTo("http://127.0.0.1:9033/admin")
//page.Contain("username")
//page.Click("")
}, func(quit chan struct{}) {
// start the server:
// ....
go startServer()
<-quit
log.Print("test quit")
}, true) // if local parameter is true, it will not be headless, and window not close when finishing tests.
}