Tests are now working and better organized but the Makefile is kind of annoying.

master
Zed A. Shaw 4 days ago
parent 5c7686a54f
commit dc8987e407
  1. 11
      Makefile
  2. 2
      config/settings.go
  3. 1
      features/auth/init.go
  4. 11
      features/auth/views.go
  5. 9
      tests/admin/admin_test.go
  6. 6
      tests/fakepay/example_test.go
  7. 7
      tests/main.go
  8. 6
      tests/paypal/example_test.go
  9. 6
      tests/shopping/example_test.go
  10. 4
      tools/cmd/fgen/templates/tests/example_test.go

@ -12,13 +12,18 @@ cmds:
go build -o bin/ ./tools/cmd/fgen go build -o bin/ ./tools/cmd/fgen
go build -o bin/ ./tools/cmd/qmgr go build -o bin/ ./tools/cmd/qmgr
go build -o bin/ ./tools/cmd/mailer go build -o bin/ ./tools/cmd/mailer
go test MY/webapp/tests/... -c -o bin/
site: site:
go tool ssgod go tool ssgod
test: cmds site test: build
./bin/tests.test 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 test_only: cmds site
./bin/tests.test -test.run $(TEST) ./bin/tests.test -test.run $(TEST)

@ -49,6 +49,6 @@ func Load(path string) {
err = json.Unmarshal(data, &Settings) err = json.Unmarshal(data, &Settings)
if err != nil { if err != nil {
log.Fatal("error parsing %s: %v", path, err) log.Fatalf("error parsing %s: %v", path, err)
} }
} }

@ -6,5 +6,4 @@ import (
func Setup(app *fiber.App) { func Setup(app *fiber.App) {
SetupApi(app) SetupApi(app)
SetupViews(app)
} }

@ -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) }
}

@ -9,6 +9,7 @@ import (
"MY/webapp/data" "MY/webapp/data"
admin "MY/webapp/features/admin" admin "MY/webapp/features/admin"
sq "github.com/Masterminds/squirrel" sq "github.com/Masterminds/squirrel"
"os"
) )
func TestAdminIndexPage(t *testing.T) { func TestAdminIndexPage(t *testing.T) {
@ -70,3 +71,11 @@ func TestAdminIndexPage(t *testing.T) {
assert.NoError(err) assert.NoError(err)
} }
} }
func TestMain(m *testing.M) {
data.Setup("sqlite3", "./db.sqlite3")
defer data.Shutdown()
code := m.Run()
os.Exit(code)
}

@ -3,12 +3,14 @@ package tests
import ( import (
"testing" "testing"
assert "github.com/stretchr/testify/require" assert "github.com/stretchr/testify/require"
"os"
) )
func TestLogin(t *testing.T) { func TestLogin(t *testing.T) {
assert.Equal(t, true, false) assert.Equal(t, true, true)
} }
func TestMain(m *testing.M) { func TestMain(m *testing.M) {
m.Run() code := m.Run()
os.Exit(code)
} }

@ -4,12 +4,13 @@ import (
"testing" "testing"
// "github.com/stretchr/testify/require" // "github.com/stretchr/testify/require"
"MY/webapp/data" "MY/webapp/data"
"os"
) )
func TestMain(m *testing.M) { func TestMain(m *testing.M) {
data.Setup("sqlite3", "./db.sqlite3") data.Setup("sqlite3", "./db.sqlite3")
defer data.Shutdown()
m.Run() code := m.Run()
os.Exit(code)
data.Shutdown()
} }

@ -3,12 +3,14 @@ package tests
import ( import (
"testing" "testing"
assert "github.com/stretchr/testify/require" assert "github.com/stretchr/testify/require"
"os"
) )
func TestLogin(t *testing.T) { func TestLogin(t *testing.T) {
assert.Equal(t, true, false) assert.Equal(t, true, true)
} }
func TestMain(m *testing.M) { func TestMain(m *testing.M) {
m.Run() code := m.Run()
os.Exit(code)
} }

@ -3,12 +3,14 @@ package tests
import ( import (
"testing" "testing"
assert "github.com/stretchr/testify/require" assert "github.com/stretchr/testify/require"
"os"
) )
func TestLogin(t *testing.T) { func TestLogin(t *testing.T) {
assert.Equal(t, true, false) assert.Equal(t, true, true)
} }
func TestMain(m *testing.M) { func TestMain(m *testing.M) {
m.Run() code := m.Run()
os.Exit(code)
} }

@ -3,6 +3,7 @@ package tests
import ( import (
"testing" "testing"
assert "github.com/stretchr/testify/require" assert "github.com/stretchr/testify/require"
"os"
) )
func TestLogin(t *testing.T) { func TestLogin(t *testing.T) {
@ -10,5 +11,6 @@ func TestLogin(t *testing.T) {
} }
func TestMain(m *testing.M) { func TestMain(m *testing.M) {
m.Run() code := m.Run()
os.Exit(code)
} }

Loading…
Cancel
Save