Skip to content
Closed
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
17 changes: 7 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 Down Expand Up @@ -41,19 +41,16 @@ type (
)

func TestMain(m *testing.M) {
env, err := testenv.New().DBEnable(true).SetUp()
if err != nil {
panic(err)
}
defer env.TearDown()

db = env.DB
ctx := context.Background()
suite := gormx.MustStartRawTestSuite(ctx)
defer func() { _ = suite.Stop(ctx) }()
db = suite.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
14 changes: 6 additions & 8 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,10 @@ 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()

db = env.DB
ctx := context.Background()
suite := gormx.MustStartRawTestSuite(ctx)
defer func() { _ = suite.Stop(ctx) }()
db = suite.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,6 +2,7 @@ package integration_test

import (
"bytes"
"context"
"encoding/json"
"net/http"
"net/http/httptest"
Expand All @@ -10,21 +11,19 @@ import (

"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()
suite := gormx.MustStartRawTestSuite(ctx)
defer func() { _ = suite.Stop(ctx) }()
TestDB = suite.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 @@ -10,12 +11,12 @@ import (

"github.com/qor5/web/v3/multipartestutils"
"github.com/theplant/gofixtures"
"github.com/theplant/testenv"
"github.com/theplant/testingutils"
"gorm.io/gorm"
"gorm.io/gorm/logger"

"github.com/qor5/admin/v3/cmd/qor5/website-template/admin"
"github.com/qor5/x/v3/gormx"
)

var (
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()
suite := gormx.MustStartRawTestSuite(ctx)
defer func() { _ = suite.Stop(ctx) }()
TestDB = suite.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()
suite := gormx.MustStartRawTestSuite(ctx)
defer func() { _ = suite.Stop(ctx) }()
TestDB = suite.DB()
TestDB.Logger = TestDB.Logger.LogMode(logger.Info)
SqlDB, _ = TestDB.DB()
m.Run()
Expand Down
15 changes: 7 additions & 8 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,11 @@ var (
)

func TestMain(m *testing.M) {
env, err := testenv.New().DBEnable(true).SetUp()
if err != nil {
panic(err)
}
defer env.TearDown()

DB = env.DB
ctx := context.Background()
suite := gormx.MustStartRawTestSuite(ctx)
defer func() { _ = suite.Stop(ctx) }()
DB = suite.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()
suite := gormx.MustStartRawTestSuite(ctx)
defer func() { _ = suite.Stop(ctx) }()
TestDB = suite.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 @@ -11,7 +12,6 @@ import (
. "github.com/qor5/web/v3/multipartestutils"
"github.com/qor5/x/v3/perm"
"github.com/theplant/gofixtures"
"github.com/theplant/testenv"
"gorm.io/gorm"
"gorm.io/gorm/logger"

Expand All @@ -23,17 +23,16 @@ import (
"github.com/qor5/admin/v3/presets/actions"
"github.com/qor5/admin/v3/publish"
"github.com/qor5/admin/v3/utils"
"github.com/qor5/x/v3/gormx"
)

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()
suite := gormx.MustStartRawTestSuite(ctx)
defer func() { _ = suite.Stop(ctx) }()
TestDB = suite.DB()
TestDB.Logger = TestDB.Logger.LogMode(logger.Info)
m.Run()
}
Expand Down
Loading
Loading