github.com/qiwihui/DBShield@v0.0.0-20171107092910-fb8553bed8ef/dbshield/db/boltdb_test.go (about) 1 package db_test 2 3 import ( 4 "io/ioutil" 5 "log" 6 "testing" 7 8 "github.com/qiwihui/DBShield/dbshield/db" 9 ) 10 11 func TestMain(m *testing.M) { 12 log.SetOutput(ioutil.Discard) // Avoid log outputs 13 m.Run() 14 } 15 16 func TestInitalDB(t *testing.T) { 17 tmpfile, err := ioutil.TempFile("", "testdb") 18 if err != nil { 19 panic(err) 20 } 21 defer tmpfile.Close() 22 path := tmpfile.Name() 23 boltDB := new(db.BoltDB) 24 err = boltDB.InitialDB(path, 0, 0) 25 if err != nil { 26 t.Error("Got error", err) 27 } 28 }