diff --git a/internal/persistence/sql/full_test.go b/internal/persistence/sql/full_test.go index ba88082c0..a90d94c65 100644 --- a/internal/persistence/sql/full_test.go +++ b/internal/persistence/sql/full_test.go @@ -5,6 +5,8 @@ import ( "fmt" "testing" + "github.com/ory/keto/internal/uuidmapping" + "github.com/gofrs/uuid" "github.com/ory/keto/internal/x/dbx" @@ -66,6 +68,11 @@ func TestPersister(t *testing.T) { // same registry, but different persisters only differing in the network ID relationtuple.IsolationTest(t, p0, p1, addNamespace(r, nspaces)) }) + + t.Run("uuidmapping.ManagerTest", func(t *testing.T) { + p, _, _ := setup(t, dsn) + uuidmapping.ManagerTest(t, p) + }) }) } } diff --git a/internal/persistence/sql/migrations/single_table_test.go b/internal/persistence/sql/migrations/single_table_test.go index c3c004947..13e3f8cf2 100644 --- a/internal/persistence/sql/migrations/single_table_test.go +++ b/internal/persistence/sql/migrations/single_table_test.go @@ -5,7 +5,6 @@ import ( "strconv" "testing" - "github.com/gofrs/uuid" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -97,15 +96,6 @@ func TestToSingleTableMigrator(t *testing.T) { assert.Equal(t, sSet, rts[1]) }) - t.Run("case=uuid mapping", func(t *testing.T) { - id := uuid.Must(uuid.NewV4()) - rep1 := "foo" - require.NoError(t, r.UUIDMappingManager().AddUUIDMapping(ctx, id, rep1)) - rep2, err := r.UUIDMappingManager().LookupUUID(ctx, id) - assert.NoError(t, err) - assert.Equal(t, rep1, rep2) - }) - t.Run("case=paginates", func(t *testing.T) { n := setup(t) diff --git a/internal/uuidmapping/definitions.go b/internal/uuidmapping/definitions.go index 7eb994827..13870aa76 100644 --- a/internal/uuidmapping/definitions.go +++ b/internal/uuidmapping/definitions.go @@ -2,6 +2,10 @@ package uuidmapping import ( "context" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" "github.com/gofrs/uuid" ) @@ -15,3 +19,15 @@ type ( LookupUUID(ctx context.Context, id uuid.UUID) (rep string, err error) } ) + +func ManagerTest(t *testing.T, m Manager) { + ctx := context.Background() + + id := uuid.Must(uuid.NewV4()) + rep1 := "foo" + require.NoError(t, m.AddUUIDMapping(ctx, id, rep1)) + + rep2, err := m.LookupUUID(ctx, id) + assert.NoError(t, err) + assert.Equal(t, rep1, rep2) +}