mirror of
https://github.com/go-sylixos/elvish.git
synced 2024-12-14 02:57:52 +08:00
1d59566aaf
This resolves issue #44.
38 lines
725 B
Go
38 lines
725 B
Go
package store
|
|
|
|
// This file also sets up the test fixture.
|
|
|
|
import (
|
|
"database/sql"
|
|
"fmt"
|
|
"testing"
|
|
|
|
_ "github.com/mattn/go-sqlite3"
|
|
)
|
|
|
|
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) {
|
|
// XXX(xiaq): Also tests EnsureDataDir
|
|
dataDir, err := EnsureDataDir()
|
|
if err != nil {
|
|
t.Errorf("EnsureDataDir() -> (*, %v), want (*, <nil>)", err)
|
|
}
|
|
|
|
_, err = NewStore(dataDir)
|
|
if err != nil {
|
|
t.Errorf("NewStore() -> (*, %v), want (*, <nil>)", err)
|
|
}
|
|
}
|