30 lines
533 B
Go
30 lines
533 B
Go
|
|
package tradebook
|
||
|
|
|
||
|
|
import (
|
||
|
|
"testing"
|
||
|
|
"path/filepath"
|
||
|
|
)
|
||
|
|
|
||
|
|
func TestOpenSQLite(t *testing.T) {
|
||
|
|
tdir := t.TempDir()
|
||
|
|
dpath := filepath.Join(tdir, "db")
|
||
|
|
|
||
|
|
tb, err := Open(Sqlite(dpath))
|
||
|
|
if (err != nil) {
|
||
|
|
t.Errorf("Open returned error: %v", err)
|
||
|
|
}
|
||
|
|
|
||
|
|
if (tb == nil) {
|
||
|
|
t.Error("Db is nil")
|
||
|
|
}
|
||
|
|
|
||
|
|
// for sqlite dsn is just a file path
|
||
|
|
if (tb.dsn != dpath) {
|
||
|
|
t.Errorf( "DSN does not match! (%v != %v).", dpath, tb.dsn)
|
||
|
|
}
|
||
|
|
|
||
|
|
if (tb.driver != "sqlite") {
|
||
|
|
t.Errorf("Driver is not sqlite (%v != %v).", tb.driver, "sqlite")
|
||
|
|
}
|
||
|
|
}
|