mirror of
https://github.com/go-shiori/shiori.git
synced 2024-11-16 22:25:13 +08:00
056be03158
Adds testing for cmd package. Adds a setup and teardown main test with a cmd test db as well as tests for account, add and update. Closes #19
28 lines
482 B
Go
28 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)
|
|
|
|
}
|