fix shared db conn in tests

absences
William Perron 2 years ago
parent 679b4136c8
commit 99d527f83e

@ -2,6 +2,7 @@ package themis
import (
"context"
"fmt"
"reflect"
"testing"
@ -9,7 +10,7 @@ import (
)
func TestStore_FindConflicts(t *testing.T) {
store, err := NewStore(TEST_CONN_STRING)
store, err := NewStore(fmt.Sprintf(TEST_CONN_STRING_PATTERN, "TestStore_FindConflicts"))
assert.NoError(t, err)
id, err := store.Claim(context.TODO(), "000000000000000001", "foo", "Bordeaux", CLAIM_TYPE_TRADE)

@ -10,10 +10,10 @@ import (
"github.com/stretchr/testify/assert"
)
const TEST_CONN_STRING = "file::memory:?cache=shared"
const TEST_CONN_STRING_PATTERN = "file:%s?mode=memory&cache=shared"
func TestStore_Claim(t *testing.T) {
store, err := NewStore(TEST_CONN_STRING)
store, err := NewStore(fmt.Sprintf(TEST_CONN_STRING_PATTERN, "TestStore_Claim"))
assert.NoError(t, err)
type args struct {
@ -78,7 +78,7 @@ func TestStore_Claim(t *testing.T) {
}
func TestAvailability(t *testing.T) {
store, err := NewStore(TEST_CONN_STRING)
store, err := NewStore(fmt.Sprintf(TEST_CONN_STRING_PATTERN, "TestAvailability"))
assert.NoError(t, err)
store.Claim(context.TODO(), "000000000000000001", "foo", "Genoa", CLAIM_TYPE_TRADE)
@ -125,9 +125,8 @@ func TestAvailability(t *testing.T) {
}
func TestDeleteClaim(t *testing.T) {
store, err := NewStore(TEST_CONN_STRING)
store, err := NewStore(fmt.Sprintf(TEST_CONN_STRING_PATTERN, "TestDeleteClaim"))
assert.NoError(t, err)
// make sure all claims are gone, this is due to how the in-memory database
// with a shared cache interacts with other tests running in parallel
_, err = store.db.ExecContext(context.TODO(), "DELETE FROM claims")
@ -150,7 +149,7 @@ func TestDeleteClaim(t *testing.T) {
}
func TestDescribeClaim(t *testing.T) {
store, err := NewStore(TEST_CONN_STRING)
store, err := NewStore(fmt.Sprintf(TEST_CONN_STRING_PATTERN, "TestDescribeClaim"))
assert.NoError(t, err)
id, err := store.Claim(context.TODO(), "000000000000000001", "foo", "Genoa", CLAIM_TYPE_TRADE)
@ -166,7 +165,7 @@ func TestDescribeClaim(t *testing.T) {
}
func TestFlush(t *testing.T) {
store, err := NewStore(TEST_CONN_STRING)
store, err := NewStore(fmt.Sprintf(TEST_CONN_STRING_PATTERN, "TestFlush"))
assert.NoError(t, err)
store.Claim(context.TODO(), "000000000000000001", "foo", "Genoa", CLAIM_TYPE_TRADE)

Loading…
Cancel
Save