test: single table migration as transaction
@@ -126,6 +126,12 @@ func TestToSingleTableMigrator(t *testing.T) {
t.Run("case=non-deserializable tuple", func(t *testing.T) {
n := setup(t)
+ valid := &relationtuple.InternalRelationTuple{
+ Namespace: n.Name,
+ Object: "o1",
+ Relation: "r",
+ Subject: &relationtuple.SubjectID{ID: "s"},
+ }
require.NoError(t, m.insertOldRelationTuples(ctx, n, &relationtuple.InternalRelationTuple{
Namespace: n.Name,
Object: "o0",
@@ -136,12 +142,19 @@ func TestToSingleTableMigrator(t *testing.T) {
Object: "o1",
Relation: "r",
Subject: &relationtuple.SubjectID{ID: "invalid#subject-id"},
- }))
+ }, valid))
err := m.MigrateNamespace(ctx, n)
require.Error(t, err)
invalid, ok := err.(ErrInvalidTuples)
require.True(t, ok)
assert.Len(t, invalid, 2)
+
+ rts, next, err := r.Persister().GetRelationTuples(ctx, &relationtuple.RelationQuery{
+ Namespace: n.Name,
+ })
+ require.NoError(t, err)
+ require.Equal(t, "", next)
+ assert.Equal(t, []*relationtuple.InternalRelationTuple{valid}, rts)
})
})
}
