diff --git a/Makefile b/Makefile index 14ff28a..3294018 100644 --- a/Makefile +++ b/Makefile @@ -12,13 +12,18 @@ cmds: go build -o bin/ ./tools/cmd/fgen go build -o bin/ ./tools/cmd/qmgr go build -o bin/ ./tools/cmd/mailer - go test MY/webapp/tests/... -c -o bin/ site: go tool ssgod -test: cmds site - ./bin/tests.test +test: build + go test ./tests/... -c -o bin/tests + ./bin/tests/admin.test + ./bin/tests/auth.test + ./bin/tests/fakepay.test + ./bin/tests/paypal.test + ./bin/tests/shopping.test + test_only: cmds site ./bin/tests.test -test.run $(TEST) diff --git a/config/settings.go b/config/settings.go index 43e09b7..f34c281 100644 --- a/config/settings.go +++ b/config/settings.go @@ -49,6 +49,6 @@ func Load(path string) { err = json.Unmarshal(data, &Settings) if err != nil { - log.Fatal("error parsing %s: %v", path, err) + log.Fatalf("error parsing %s: %v", path, err) } } diff --git a/features/auth/init.go b/features/auth/init.go index cabe5d1..185a36d 100644 --- a/features/auth/init.go +++ b/features/auth/init.go @@ -6,5 +6,4 @@ import ( func Setup(app *fiber.App) { SetupApi(app) - SetupViews(app) } diff --git a/features/auth/views.go b/features/auth/views.go deleted file mode 100644 index d31fe36..0000000 --- a/features/auth/views.go +++ /dev/null @@ -1,11 +0,0 @@ -package features_auth - -import ( - "github.com/gofiber/fiber/v2" - . "MY/webapp/common" -) - -func SetupViews(app *fiber.App) { - err := ConfigViews(app, "views/auth") - if err != nil { panic(err) } -} diff --git a/tests/admin/admin_test.go b/tests/admin/admin_test.go index 5720e90..caff5b0 100644 --- a/tests/admin/admin_test.go +++ b/tests/admin/admin_test.go @@ -9,6 +9,7 @@ import ( "MY/webapp/data" admin "MY/webapp/features/admin" sq "github.com/Masterminds/squirrel" + "os" ) func TestAdminIndexPage(t *testing.T) { @@ -70,3 +71,11 @@ func TestAdminIndexPage(t *testing.T) { assert.NoError(err) } } + +func TestMain(m *testing.M) { + data.Setup("sqlite3", "./db.sqlite3") + defer data.Shutdown() + + code := m.Run() + os.Exit(code) +} diff --git a/tests/fakepay/example_test.go b/tests/fakepay/example_test.go index 96f333d..7c70add 100644 --- a/tests/fakepay/example_test.go +++ b/tests/fakepay/example_test.go @@ -3,12 +3,14 @@ package tests import ( "testing" assert "github.com/stretchr/testify/require" + "os" ) func TestLogin(t *testing.T) { - assert.Equal(t, true, false) + assert.Equal(t, true, true) } func TestMain(m *testing.M) { - m.Run() + code := m.Run() + os.Exit(code) } diff --git a/tests/main.go b/tests/main.go index a5c0af0..d3aa15f 100644 --- a/tests/main.go +++ b/tests/main.go @@ -4,12 +4,13 @@ import ( "testing" // "github.com/stretchr/testify/require" "MY/webapp/data" + "os" ) func TestMain(m *testing.M) { data.Setup("sqlite3", "./db.sqlite3") + defer data.Shutdown() - m.Run() - - data.Shutdown() + code := m.Run() + os.Exit(code) } diff --git a/tests/paypal/example_test.go b/tests/paypal/example_test.go index 96f333d..7c70add 100644 --- a/tests/paypal/example_test.go +++ b/tests/paypal/example_test.go @@ -3,12 +3,14 @@ package tests import ( "testing" assert "github.com/stretchr/testify/require" + "os" ) func TestLogin(t *testing.T) { - assert.Equal(t, true, false) + assert.Equal(t, true, true) } func TestMain(m *testing.M) { - m.Run() + code := m.Run() + os.Exit(code) } diff --git a/tests/shopping/example_test.go b/tests/shopping/example_test.go index 96f333d..7c70add 100644 --- a/tests/shopping/example_test.go +++ b/tests/shopping/example_test.go @@ -3,12 +3,14 @@ package tests import ( "testing" assert "github.com/stretchr/testify/require" + "os" ) func TestLogin(t *testing.T) { - assert.Equal(t, true, false) + assert.Equal(t, true, true) } func TestMain(m *testing.M) { - m.Run() + code := m.Run() + os.Exit(code) } diff --git a/tools/cmd/fgen/templates/tests/example_test.go b/tools/cmd/fgen/templates/tests/example_test.go index 96f333d..44130d7 100644 --- a/tools/cmd/fgen/templates/tests/example_test.go +++ b/tools/cmd/fgen/templates/tests/example_test.go @@ -3,6 +3,7 @@ package tests import ( "testing" assert "github.com/stretchr/testify/require" + "os" ) func TestLogin(t *testing.T) { @@ -10,5 +11,6 @@ func TestLogin(t *testing.T) { } func TestMain(m *testing.M) { - m.Run() + code := m.Run() + os.Exit(code) }