wallet-sync-server/store/store_test.go

33 lines
481 B
Go
Raw Normal View History

package store
import (
2022-06-27 17:28:39 +02:00
"io/ioutil"
"os"
"testing"
)
2022-06-27 17:28:39 +02:00
func StoreTestInit(t *testing.T) (s Store, tmpFile *os.File) {
s = Store{}
2022-06-27 17:28:39 +02:00
tmpFile, err := ioutil.TempFile(os.TempDir(), "sqlite-test-")
if err != nil {
t.Fatalf("DB setup failure: %+v", err)
return
}
2022-06-27 17:28:39 +02:00
s.Init(tmpFile.Name())
2022-06-27 17:28:39 +02:00
err = s.Migrate()
if err != nil {
2022-06-27 17:28:39 +02:00
t.Fatalf("DB setup failure: %+v", err)
}
2022-06-27 17:28:39 +02:00
return
}
2022-06-27 17:28:39 +02:00
func StoreTestCleanup(tmpFile *os.File) {
if tmpFile != nil {
os.Remove(tmpFile.Name())
}
}