File tree Expand file tree Collapse file tree 2 files changed +19
-18
lines changed Expand file tree Collapse file tree 2 files changed +19
-18
lines changed Original file line number Diff line number Diff line change @@ -8,7 +8,11 @@ import (
8
8
9
9
"code.gitea.io/gitea/modules/setting"
10
10
11
+ "github.com/go-xorm/core"
12
+ "github.com/go-xorm/xorm"
13
+ _ "github.com/mattn/go-sqlite3" // for the test engine
11
14
"github.com/stretchr/testify/assert"
15
+ "gopkg.in/testfixtures.v2"
12
16
)
13
17
14
18
// TestFixturesAreConsistent assert that test fixtures are consistent
@@ -17,6 +21,21 @@ func TestFixturesAreConsistent(t *testing.T) {
17
21
CheckConsistencyForAll (t )
18
22
}
19
23
24
+ // CreateTestEngine create an xorm engine for testing
25
+ func CreateTestEngine () error {
26
+ var err error
27
+ x , err = xorm .NewEngine ("sqlite3" , "file::memory:?cache=shared" )
28
+ if err != nil {
29
+ return err
30
+ }
31
+ x .SetMapper (core.GonicMapper {})
32
+ if err = x .StoreEngine ("InnoDB" ).Sync2 (tables ... ); err != nil {
33
+ return err
34
+ }
35
+
36
+ return InitFixtures (& testfixtures.SQLite {}, "fixtures/" )
37
+ }
38
+
20
39
func TestMain (m * testing.M ) {
21
40
if err := CreateTestEngine (); err != nil {
22
41
fmt .Printf ("Error creating test engine: %v\n " , err )
Original file line number Diff line number Diff line change @@ -7,31 +7,13 @@ package models
7
7
import (
8
8
"testing"
9
9
10
- "github.com/go-xorm/core"
11
10
"github.com/go-xorm/xorm"
12
- _ "github.com/mattn/go-sqlite3" // for the test engine
13
11
"github.com/stretchr/testify/assert"
14
- "gopkg.in/testfixtures.v2"
15
12
)
16
13
17
14
// NonexistentID an ID that will never exist
18
15
const NonexistentID = 9223372036854775807
19
16
20
- // CreateTestEngine create an xorm engine for testing
21
- func CreateTestEngine () error {
22
- var err error
23
- x , err = xorm .NewEngine ("sqlite3" , "file::memory:?cache=shared" )
24
- if err != nil {
25
- return err
26
- }
27
- x .SetMapper (core.GonicMapper {})
28
- if err = x .StoreEngine ("InnoDB" ).Sync2 (tables ... ); err != nil {
29
- return err
30
- }
31
-
32
- return InitFixtures (& testfixtures.SQLite {}, "fixtures/" )
33
- }
34
-
35
17
// PrepareTestDatabase load test fixtures into test database
36
18
func PrepareTestDatabase () error {
37
19
return LoadFixtures ()
You can’t perform that action at this time.
0 commit comments