mirror of
https://git.sr.ht/~ashkeel/strimertul
synced 2024-09-30 02:40:33 +00:00
32 lines
579 B
Go
32 lines
579 B
Go
package database
|
|
|
|
import (
|
|
"testing"
|
|
|
|
kv "git.sr.ht/~ashkeel/kilovolt/v12"
|
|
)
|
|
|
|
func CreateInMemoryLocalClient(t *testing.T) (*LocalDBClient, kv.Driver) {
|
|
// Create in-memory store and hub
|
|
inMemoryStore := kv.MakeBackend()
|
|
hub, err := kv.NewHub(inMemoryStore, kv.HubOptions{})
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
go hub.Run()
|
|
|
|
// Create local client
|
|
client, err := NewLocalClient(hub)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
return client, inMemoryStore
|
|
}
|
|
|
|
func CleanupLocalClient(client *LocalDBClient) {
|
|
if client.hub != nil {
|
|
_ = client.Close()
|
|
client.hub.Close()
|
|
}
|
|
}
|