Added tests for page.
This commit is contained in:
parent
3525d5d704
commit
8eb8264d6e
2 changed files with 113 additions and 0 deletions
35
controller/controller_test.go
Normal file
35
controller/controller_test.go
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
package controller
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"os"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"goweb/config"
|
||||
"goweb/services"
|
||||
|
||||
"github.com/labstack/echo/v4"
|
||||
)
|
||||
|
||||
var (
|
||||
c *services.Container
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
// Set the environment to test
|
||||
config.SwitchEnvironment(config.EnvTest)
|
||||
|
||||
// Create a new container
|
||||
c = services.NewContainer()
|
||||
|
||||
// Run tests
|
||||
exitVal := m.Run()
|
||||
os.Exit(exitVal)
|
||||
}
|
||||
|
||||
func newContext(url string) echo.Context {
|
||||
req := httptest.NewRequest(http.MethodPost, url, strings.NewReader(""))
|
||||
return c.Web.NewContext(req, httptest.NewRecorder())
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue