2014-10-01 06:57:38 +08:00
|
|
|
package store
|
|
|
|
|
|
|
|
// This file also sets up the test fixture.
|
|
|
|
|
|
|
|
import (
|
|
|
|
"database/sql"
|
|
|
|
"fmt"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
var tStore *Store
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
db, err := sql.Open("sqlite3", ":memory:")
|
|
|
|
if err != nil {
|
|
|
|
panic(fmt.Sprintf("Failed to create in-memory SQLite3 DB: %v", err))
|
|
|
|
}
|
|
|
|
tStore, err = NewStoreDB(db)
|
|
|
|
if err != nil {
|
|
|
|
panic(fmt.Sprintf("Failed to create Store instance: %v", err))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestNewStore(t *testing.T) {
|
2015-02-24 01:36:46 +08:00
|
|
|
// XXX(xiaq): Also tests EnsureDataDir
|
|
|
|
dataDir, err := EnsureDataDir()
|
|
|
|
if err != nil {
|
|
|
|
t.Errorf("EnsureDataDir() -> (*, %v), want (*, <nil>)", err)
|
|
|
|
}
|
|
|
|
|
2016-02-13 07:44:14 +08:00
|
|
|
_, err = NewStore(dataDir + "/db")
|
2014-10-01 06:57:38 +08:00
|
|
|
if err != nil {
|
|
|
|
t.Errorf("NewStore() -> (*, %v), want (*, <nil>)", err)
|
|
|
|
}
|
|
|
|
}
|