Skip to content

Commit

Permalink
Chain some stuff together
Browse files Browse the repository at this point in the history
  • Loading branch information
tstirrat15 committed Oct 30, 2024
1 parent 1751ac2 commit 7bff3f9
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions pkg/wasm/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ func TestZedCommand(t *testing.T) {
require.NoError(t, err)

require.Contains(t, updatedContext.Schema, "definition document")
require.Equal(t, `document:first#viewer@user:fred[somecaveat:{"somecondition":42}]`, tuple.CoreRelationToString(updatedContext.Relationships[0]))
require.Equal(t, "document:first#viewer@user:tom", tuple.CoreRelationToString(updatedContext.Relationships[1]))
require.Equal(t, `document:first#viewer@user:fred[somecaveat:{"somecondition":42}]`, stringifyTuple(updatedContext.Relationships[0]))
require.Equal(t, "document:first#viewer@user:tom", stringifyTuple(updatedContext.Relationships[1]))
require.Len(t, updatedContext.Relationships, 2)

// Run the actual command.
Expand All @@ -69,3 +69,9 @@ func TestZedCommand(t *testing.T) {
require.NoError(t, err)
require.Len(t, updatedContext.Relationships, 3)
}

// NOTE: this is required to preserve caveat context.
// tuple.CoreRelationToString elides the caveat context.
func stringifyTuple(relationtuple *v1.RelationTuple) string {
return tuple.MustString(tuple.FromCoreRelationTuple(relationtuple))
}

0 comments on commit 7bff3f9

Please sign in to comment.