mirror of
https://github.com/go-shiori/shiori.git
synced 2024-11-17 06:34:55 +08:00
29 lines
482 B
Go
29 lines
482 B
Go
|
package cmd
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
"os"
|
||
|
"testing"
|
||
|
|
||
|
db "github.com/RadhiFadlillah/shiori/database"
|
||
|
_ "github.com/mattn/go-sqlite3"
|
||
|
)
|
||
|
|
||
|
func TestMain(m *testing.M) {
|
||
|
testDBFile := "shiori_test.db"
|
||
|
sqliteDB, err := db.OpenSQLiteDatabase(testDBFile)
|
||
|
if err != nil {
|
||
|
fmt.Printf("failed to create tests DB: %v", err)
|
||
|
os.Exit(1)
|
||
|
}
|
||
|
DB = sqliteDB
|
||
|
|
||
|
code := m.Run()
|
||
|
|
||
|
if err := os.Remove(testDBFile); err != nil {
|
||
|
fmt.Printf("failed to delete tests DB: %v", err)
|
||
|
}
|
||
|
os.Exit(code)
|
||
|
|
||
|
}
|