main_test.go 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. package main
  2. import (
  3. "github.com/GoAdminGroup/demo/tables"
  4. "github.com/GoAdminGroup/go-admin/modules/config"
  5. "github.com/GoAdminGroup/go-admin/tests"
  6. "github.com/GoAdminGroup/go-admin/tests/common"
  7. "github.com/GoAdminGroup/go-admin/tests/frameworks/gin"
  8. "github.com/GoAdminGroup/go-admin/tests/web"
  9. "github.com/gavv/httpexpect"
  10. "testing"
  11. )
  12. // Black box testing
  13. func TestExampleBlackBox(t *testing.T) {
  14. tests.BlackBoxTestSuit(t, gin.NewHandler, config.DatabaseList{
  15. "default": config.Database{
  16. File: "./admin_test.db",
  17. Driver: "sqlite",
  18. },
  19. }, tables.Generators, func(cfg config.DatabaseList) {
  20. // Data cleaner of the framework
  21. tests.Cleaner(cfg)
  22. // Clean your own data:
  23. // ...
  24. }, func(e *httpexpect.Expect) {
  25. // Test cases of the framework
  26. common.Test(e)
  27. // Write your own API test, for example:
  28. // More usages: https://github.com/gavv/httpexpect
  29. // e.POST("/signin").Expect().Status(http.StatusOK)
  30. })
  31. }
  32. // User acceptance testing
  33. func TestExampleUserAcceptance(t *testing.T) {
  34. web.UserAcceptanceTestSuit(t, func(t *testing.T, page *web.Page) {
  35. // Write test case base on chromedriver, for example:
  36. // More usages: https://github.com/sclevine/agouti
  37. page.NavigateTo("http://127.0.0.1:9033/admin")
  38. //page.Contain("username")
  39. //page.Click("")
  40. }, func(quit chan struct{}) {
  41. // start the server:
  42. // ....
  43. }, true) // if local parameter is true, it will not be headless, and window not close when finishing tests.
  44. }