Added tests for page.

This commit is contained in:
mikestefanello 2021-12-18 17:24:46 -05:00
parent 3525d5d704
commit 8eb8264d6e
2 changed files with 113 additions and 0 deletions

View 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())
}