2019-09-15 21:20:05 +00:00
|
|
|
package persistence
|
|
|
|
|
|
|
|
import (
|
2020-02-06 23:54:13 +00:00
|
|
|
"os"
|
2019-09-15 21:20:05 +00:00
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestBoltPersistence_Open(t *testing.T) {
|
2020-02-06 23:54:13 +00:00
|
|
|
os.Remove("test.dbgi")
|
2021-06-09 17:36:34 +00:00
|
|
|
db := new(BoltPersistence)
|
2019-09-15 21:20:05 +00:00
|
|
|
db.Open("test.dbgi")
|
|
|
|
db.Setup([]string{"tokens"})
|
2020-02-06 23:54:13 +00:00
|
|
|
// 2020.02: Fails in WSL1 because of a mmap issue.
|
|
|
|
// https://github.com/microsoft/WSL/issues/4873
|
|
|
|
// Scheduled to be fixed in the 20h1 Win10 release
|
2019-09-15 21:20:05 +00:00
|
|
|
db.Persist("tokens", "random_value", true)
|
|
|
|
|
|
|
|
var exists bool
|
|
|
|
db.Load("tokens", "random_value", &exists)
|
|
|
|
|
|
|
|
if exists {
|
|
|
|
t.Logf("Successfully stored: %v", exists)
|
|
|
|
} else {
|
|
|
|
t.Fatalf("Failure to store record in DB!")
|
|
|
|
}
|
|
|
|
db.Close()
|
|
|
|
}
|