diff --git a/init.sh b/init.sh index 5c13271..6b155d8 100644 --- a/init.sh +++ b/init.sh @@ -2,7 +2,7 @@ port=57017 -if ! curl -sS localhost:$port > /dev/null; then +if false && ! curl -sS localhost:$port > /dev/null; then prefix=/tmp/whodunit.db mkdir -p $prefix/data mongod \ @@ -26,3 +26,6 @@ remove() { } export DBURI=${DB_URI:-"mongodb://localhost:$port"} + +export DRIVERTYPE=boltdb +export DBURI=$(mktemp) diff --git a/storage/driver/boltdb.go b/storage/driver/boltdb.go index 1d1850f..1ea4f61 100644 --- a/storage/driver/boltdb.go +++ b/storage/driver/boltdb.go @@ -9,6 +9,7 @@ import ( "os" "regexp" "strings" + "time" "github.com/boltdb/bolt" "go.mongodb.org/mongo-driver/bson" @@ -25,7 +26,9 @@ type BoltDB struct { func NewBoltDB() *BoltDB { config := config.New() - db, err := bolt.Open(config.DBURI, os.ModePerm, nil) + db, err := bolt.Open(config.DBURI, os.ModePerm, &bolt.Options{ + Timeout: time.Second * 3, + }) if err != nil { panic(err) } diff --git a/view/json_test.go b/view/json_test.go index 6ef95f8..8b409cf 100644 --- a/view/json_test.go +++ b/view/json_test.go @@ -25,6 +25,8 @@ func TestJSON(t *testing.T) { } os.Args = os.Args[:1] + t.Logf("config: %+v", config.New()) + g := storage.NewGraph() ones := fillDB(t, g) want := ones[len(ones)-1]