2018-01-21 20:19:54 +00:00
|
|
|
package database
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"git.xeserv.us/xena/route/internal/routecrypto"
|
|
|
|
"github.com/Xe/uuid"
|
|
|
|
"golang.org/x/net/context"
|
|
|
|
)
|
|
|
|
|
|
|
|
func newTestBoltStorage(t *testing.T) (Storage, string, context.Context, context.CancelFunc) {
|
|
|
|
k, err := routecrypto.ParseKey(cryptoKey)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
p := uuid.New()
|
|
|
|
|
|
|
|
st, err := NewBoltStorage(p, k)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
|
|
|
|
|
|
return st, p, ctx, cancel
|
|
|
|
}
|
2018-01-22 02:09:24 +00:00
|
|
|
|
|
|
|
func newTestPostgresStorage(t *testing.T, url string) (Storage, context.Context, context.CancelFunc) {
|
|
|
|
k, err := routecrypto.ParseKey(cryptoKey)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
st, err := NewPostgresStorage(url, k)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
|
|
|
|
|
|
return st, ctx, cancel
|
|
|
|
}
|