Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support multiple tuple files in tests #233

Open
xtsee opened this issue Jan 21, 2024 · 1 comment
Open

Support multiple tuple files in tests #233

xtsee opened this issue Jan 21, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@xtsee
Copy link

xtsee commented Jan 21, 2024

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

tests: # required
  - name: test-1
    # tuple_file: ./tuples.yaml # tuples that would apply per test
    # tuple_file: # or multiple
    #   - ./tuples-1.yaml
    #   - ./tuples-2.yaml
@rhamzeh rhamzeh added the enhancement New feature or request label Jan 26, 2024
@rclayton-godaddy
Copy link

rclayton-godaddy commented Feb 25, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants