Skip to content

Commit

Permalink
repro: namespace/caveat changes cause an incorrect delete event
Browse files Browse the repository at this point in the history
  • Loading branch information
vroldanbet committed Nov 29, 2024
1 parent a251139 commit a5e5087
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions pkg/datastore/test/watch.go
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,7 @@ func WatchSchemaTest(t *testing.T, tester DatastoreTester) {
changes, errchan := ds.Watch(ctx, lowestRevision, datastore.WatchJustSchema())
require.Zero(len(errchan))

// Addition
// Write an updated schema and ensure the changes are returned.
_, err = ds.ReadWriteTx(ctx, func(ctx context.Context, rwt datastore.ReadWriteTransaction) error {
err := rwt.WriteNamespaces(ctx, &core.NamespaceDefinition{
Expand All @@ -561,6 +562,37 @@ func WatchSchemaTest(t *testing.T, tester DatastoreTester) {
},
}, changes, errchan, false)

// Changed
_, err = ds.ReadWriteTx(ctx, func(ctx context.Context, rwt datastore.ReadWriteTransaction) error {
err := rwt.WriteNamespaces(ctx, &core.NamespaceDefinition{
Name: "somenewnamespace",
Relation: []*core.Relation{
{
Name: "anotherrelation",
},
},
})
if err != nil {
return err
}

return rwt.WriteCaveats(ctx, []*core.CaveatDefinition{
{
Name: "somenewcaveat",
SerializedExpression: []byte("123"),
},
})
})
require.NoError(err)

verifyMixedUpdates(require, [][]string{
{
"changed:somenewnamespace",
"changed:somenewcaveat",
},
}, changes, errchan, false)

// Removed
// Delete some namespaces and caveats.
_, err = ds.ReadWriteTx(ctx, func(ctx context.Context, rwt datastore.ReadWriteTransaction) error {
err := rwt.DeleteNamespaces(ctx, "somenewnamespace")
Expand Down

0 comments on commit a5e5087

Please sign in to comment.