Open xtsee opened 7 months ago
Bump on this use case. I have a set of initial tuples to set up global relationships between models. I want to source the initial tuples as an external file and then supply the test tuples in the YAML.
Update - looking through the source code, I found out you can add tuple_files
directly on the test. These will be merged with the tuples at the root of the test file:
name: Auditor
model_file: './model.fga'
tuples:
- user: employee:sbird
relation: member
object: auditor:global
- user: employee:mrapinoe
relation: member
object: admin:global
- user: admin:global#member
relation: owner
object: namespace:foo
- user: auditor:global#member
relation: observer
object: namespace:foo
tests:
- name: "direct relation to auditor:global"
tuple_file: './initial_tuples.json'
check:
- user: employee:sbird
object: auditor:global
assertions:
member: true
- name: "admin is an auditor"
tuple_file: './initial_tuples.json'
check:
- user: employee:mrapinoe
object: auditor:global
assertions:
member: true
- name: "global auditor is a workflow observer"
tuple_file: './initial_tuples.json'
check:
- user: employee:sbird
object: namespace:foo
assertions:
observer: true
Scope Allowing multiple tuple files gives you the option to break up your fixtures data (tuples) and reuse them across different tests. For example, you might have a set of tuples that contain all companies and another set of tuples for teams. This should make managing the test data a lot easier.
Example