shiori/cmd/cmd_test.go
Peter Etelej 056be03158
Add tests for cmd package
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
2018-03-03 08:03:54 +03:00

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)
}