Skip to content

Commit

Permalink
test: add graph tests for recursive models (#330)
Browse files Browse the repository at this point in the history
  • Loading branch information
miparnisari authored Aug 30, 2024
2 parents c95a062 + b8cfda3 commit e8e4f51
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions pkg/go/graph/graph_builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,29 @@ rankdir=BT
// Edge definitions.
2 -> 1 [label=direct];
4 -> 2 [label=direct];
}`,
},
`direct_assignment_with_usersets_recursive`: {
model: `
model
schema 1.1
type folder
relations
define viewer: [user,folder#viewer]
type user`,
expectedOutput: `digraph {
graph [
rankdir=BT
];
// Node definitions.
0 [label=folder];
1 [label="folder#viewer"];
2 [label=user];
// Edge definitions.
1 -> 1 [label=direct];
2 -> 1 [label=direct];
}`,
},
`direct_assignment_with_conditions`: { // conditions are not represented and edges are de-duped
Expand Down Expand Up @@ -223,6 +246,34 @@ rankdir=BT
2 -> 1 [label=direct];
4 -> 3 [headlabel="(document#parent)"];
5 -> 4 [label=direct];
}`,
},
`tuple_to_userset_recursive`: {
model: `
model
schema 1.1
type user
type folder
relations
define parent: [folder]
define viewer: [user] or viewer from parent`,
expectedOutput: `digraph {
graph [
rankdir=BT
];
// Node definitions.
0 [label=folder];
1 [label="folder#parent"];
2 [label="folder#viewer"];
3 [label=union];
4 [label=user];
// Edge definitions.
0 -> 1 [label=direct];
2 -> 3 [headlabel="(folder#parent)"];
3 -> 2 [style=dashed];
4 -> 3 [label=direct];
}`,
},
`tuple_to_userset_two_related_types`: {
Expand Down

0 comments on commit e8e4f51

Please sign in to comment.