Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions activity/builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (
"github.com/qor5/admin/v3/presets"
"github.com/qor5/admin/v3/presets/gorm2op"
"github.com/qor5/web/v3"
"github.com/qor5/x/v3/gormx"
"github.com/stretchr/testify/require"
"github.com/theplant/testenv"
"gorm.io/gorm"
"gorm.io/gorm/logger"
)
Expand All @@ -24,7 +24,7 @@ type (
VersionName string
Title string
Description string
Widgets Widgets
Widgets Widgets `gorm:"-"`
}
Widgets []Widget
Widget struct {
Expand All @@ -41,19 +41,17 @@ type (
)

func TestMain(m *testing.M) {
env, err := testenv.New().DBEnable(true).SetUp()
if err != nil {
panic(err)
}
defer env.TearDown()
ctx := context.Background()
testSuite := gormx.MustStartTestSuite(ctx)
defer testSuite.Stop(ctx)

db = env.DB
db = testSuite.DB()
db.Logger = db.Logger.LogMode(logger.Info)

if err = AutoMigrate(db, ""); err != nil {
if err := AutoMigrate(db, ""); err != nil {
panic(err)
}
if err = db.AutoMigrate(&TestActivityModel{}); err != nil {
if err := db.AutoMigrate(&TestActivityModel{}); err != nil {
panic(err)
}

Expand Down
13 changes: 6 additions & 7 deletions activity/tests/gorm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ package activity

import (
"cmp"
"context"
"testing"

"github.com/qor5/x/v3/gormx"
"github.com/stretchr/testify/require"
"github.com/theplant/testenv"
"gorm.io/gorm"
"gorm.io/gorm/logger"
"gorm.io/gorm/schema"
Expand All @@ -24,13 +25,11 @@ type Bar struct {
var db *gorm.DB

func TestMain(m *testing.M) {
env, err := testenv.New().DBEnable(true).SetUp()
if err != nil {
panic(err)
}
defer env.TearDown()
ctx := context.Background()
testSuite := gormx.MustStartTestSuite(ctx)
defer testSuite.Stop(ctx)

db = env.DB
db = testSuite.DB()
db.Logger = db.Logger.LogMode(logger.Info)

m.Run()
Expand Down
13 changes: 6 additions & 7 deletions autocomplete/integration/autocomplete_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,28 @@ package integration_test

import (
"bytes"
"context"
"encoding/json"
"net/http"
"net/http/httptest"
"net/http/httputil"
"testing"

"github.com/qor5/admin/v3/autocomplete"
"github.com/qor5/x/v3/gormx"

"github.com/theplant/gofixtures"
"github.com/theplant/testenv"
"gorm.io/gorm"
"gorm.io/gorm/logger"
)

var TestDB *gorm.DB

func TestMain(m *testing.M) {
env, err := testenv.New().DBEnable(true).SetUp()
if err != nil {
panic(err)
}
defer env.TearDown()
TestDB = env.DB
ctx := context.Background()
testSuite := gormx.MustStartTestSuite(ctx)
defer testSuite.Stop(ctx)
TestDB = testSuite.DB()
TestDB.Logger = TestDB.Logger.LogMode(logger.Info)
m.Run()
}
Expand Down
13 changes: 6 additions & 7 deletions cmd/qor5/website-template/admin/integration_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package admin_test

import (
"context"
"database/sql"
"net/http"
"net/http/httptest"
Expand All @@ -9,8 +10,8 @@ import (
"github.com/qor5/admin/v3/pagebuilder"

"github.com/qor5/web/v3/multipartestutils"
"github.com/qor5/x/v3/gormx"
"github.com/theplant/gofixtures"
"github.com/theplant/testenv"
"github.com/theplant/testingutils"
"gorm.io/gorm"
"gorm.io/gorm/logger"
Expand All @@ -24,12 +25,10 @@ var (
)

func TestMain(m *testing.M) {
env, err := testenv.New().DBEnable(true).SetUp()
if err != nil {
panic(err)
}
defer env.TearDown()
TestDB = env.DB
ctx := context.Background()
testSuite := gormx.MustStartTestSuite(ctx)
defer testSuite.Stop(ctx)
TestDB = testSuite.DB()
TestDB.Logger = TestDB.Logger.LogMode(logger.Info)
SqlDB, _ = TestDB.DB()
m.Run()
Expand Down
13 changes: 6 additions & 7 deletions docs/docsrc/examples/examples_admin/db_test.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package examples_admin

import (
"context"
"database/sql"
"testing"

"github.com/theplant/testenv"
"github.com/qor5/x/v3/gormx"
"gorm.io/gorm"
"gorm.io/gorm/logger"
)
Expand All @@ -15,12 +16,10 @@ var (
)

func TestMain(m *testing.M) {
env, err := testenv.New().DBEnable(true).SetUp()
if err != nil {
panic(err)
}
defer env.TearDown()
TestDB = env.DB
ctx := context.Background()
testSuite := gormx.MustStartTestSuite(ctx)
defer testSuite.Stop(ctx)
TestDB = testSuite.DB()
TestDB.Logger = TestDB.Logger.LogMode(logger.Info)
SqlDB, _ = TestDB.DB()
m.Run()
Expand Down
14 changes: 7 additions & 7 deletions docs/docsrc/examples/examples_admin/publish_test/env_test.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
package publish_test

import (
"context"
"database/sql"
"net/http"
"testing"

"github.com/qor5/admin/v3/docs/docsrc/examples/examples_admin"
"github.com/qor5/admin/v3/presets"
"github.com/qor5/admin/v3/presets/gorm2op"
"github.com/theplant/testenv"
"github.com/qor5/x/v3/gormx"
"gorm.io/gorm"
)

Expand All @@ -19,13 +20,12 @@ var (
)

func TestMain(m *testing.M) {
env, err := testenv.New().DBEnable(true).SetUp()
if err != nil {
panic(err)
}
defer env.TearDown()
ctx := context.Background()
testSuite := gormx.MustStartTestSuite(ctx)
defer testSuite.Stop(ctx)

DB = env.DB
DB = testSuite.DB()
var err error
SQLDB, err = DB.DB()
if err != nil {
panic(err)
Expand Down
13 changes: 6 additions & 7 deletions docs/docsrc/examples/examples_presets/presets_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package examples_presets

import (
"context"
"database/sql"
"net/http"
"net/http/httptest"
Expand All @@ -9,7 +10,7 @@ import (
"github.com/qor5/admin/v3/presets"
"github.com/qor5/admin/v3/presets/gorm2op"
"github.com/qor5/web/v3/multipartestutils"
"github.com/theplant/testenv"
"github.com/qor5/x/v3/gormx"
"gorm.io/gorm"
"gorm.io/gorm/logger"
)
Expand All @@ -20,12 +21,10 @@ var (
)

func TestMain(m *testing.M) {
env, err := testenv.New().DBEnable(true).SetUp()
if err != nil {
panic(err)
}
defer env.TearDown()
TestDB = env.DB
ctx := context.Background()
testSuite := gormx.MustStartTestSuite(ctx)
defer testSuite.Stop(ctx)
TestDB = testSuite.DB()
TestDB.Logger = TestDB.Logger.LogMode(logger.Info)
SqlDB, _ = TestDB.DB()
m.Run()
Expand Down
13 changes: 6 additions & 7 deletions example/integration/pagebuilder_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package integration_test

import (
"context"
"fmt"
"net/http"
"net/http/httptest"
Expand All @@ -9,9 +10,9 @@ import (

"github.com/qor5/web/v3"
. "github.com/qor5/web/v3/multipartestutils"
"github.com/qor5/x/v3/gormx"
"github.com/qor5/x/v3/perm"
"github.com/theplant/gofixtures"
"github.com/theplant/testenv"
"gorm.io/gorm"
"gorm.io/gorm/logger"

Expand All @@ -28,12 +29,10 @@ import (
var TestDB *gorm.DB

func TestMain(m *testing.M) {
env, err := testenv.New().DBEnable(true).SetUp()
if err != nil {
panic(err)
}
defer env.TearDown()
TestDB = env.DB
ctx := context.Background()
testSuite := gormx.MustStartTestSuite(ctx)
defer testSuite.Stop(ctx)
TestDB = testSuite.DB()
TestDB.Logger = TestDB.Logger.LogMode(logger.Info)
m.Run()
}
Expand Down
Loading
Loading