diff --git a/pkg/wasm/main.go b/pkg/wasm/main.go index f17622a..76e1a70 100644 --- a/pkg/wasm/main.go +++ b/pkg/wasm/main.go @@ -180,12 +180,12 @@ func runZedCommand(rootCmd *cobra.Command, requestContextJSON string, stringPara if err != nil { return zedCommandResult{Error: err.Error()} } - defer it.Close() - - for rel := it.Next(); rel != nil; rel = it.Next() { - relationships = append(relationships, rel) + for rel, err := range it { + if err != nil { + return zedCommandResult{Error: err.Error()} + } + relationships = append(relationships, rel.ToCoreTuple()) } - it.Close() } caveatDefs, err := reader.ListAllCaveats(ctx) diff --git a/pkg/wasm/main_test.go b/pkg/wasm/main_test.go index c242626..c02d254 100644 --- a/pkg/wasm/main_test.go +++ b/pkg/wasm/main_test.go @@ -33,8 +33,8 @@ func TestZedCommand(t *testing.T) { }`, Relationships: []*v1.RelationTuple{ - tuple.MustParse(`document:first#viewer@user:fred[somecaveat:{"somecondition": 42}]`), - tuple.MustParse("document:first#viewer@user:tom"), + tuple.MustParse(`document:first#viewer@user:fred[somecaveat:{"somecondition": 42}]`).ToCoreTuple(), + tuple.MustParse("document:first#viewer@user:tom").ToCoreTuple(), }, } @@ -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.MustString(updatedContext.Relationships[0])) - require.Equal(t, "document:first#viewer@user:tom", tuple.MustString(updatedContext.Relationships[1])) + 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.Len(t, updatedContext.Relationships, 2) // Run the actual command.