Last active
December 2, 2024 11:51
-
-
Save ewanharris/c270eab0f4899aea5a1c24d9ee32cc49 to your computer and use it in GitHub Desktop.
Example of separating tests
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- name: "folder-document-access-checks" | |
description: "" | |
tuple_file: ./folder-document-access_tuples.json | |
check: | |
- user: user:anne | |
object: folder:product-2021 | |
assertions: | |
can_view: true | |
can_write: true | |
can_share: false | |
- user: user:beth | |
object: folder:product-2021 | |
assertions: | |
can_view: true | |
can_write: false | |
can_share: false | |
- user: user:anne | |
object: folder:product-2021Q1 | |
assertions: | |
can_view: true | |
can_write: true | |
can_share: false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- name: "folder-document-access-list-objects" | |
description: "" | |
tuple_file: ./folder-document-access_tuples.json | |
list_objects: | |
- user: user:anne | |
type: folder | |
assertions: | |
can_view: | |
- folder:product | |
- folder:product-2021 | |
- folder:product-2021Q1 | |
can_write: | |
- folder:product | |
- folder:product-2021 | |
- folder:product-2021Q1 | |
can_share: | |
- folder:product | |
- user: user:beth | |
type: folder | |
assertions: | |
can_view: | |
- folder:product-2021 | |
- folder:product-2021Q1 | |
can_write: [] | |
can_share: [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- name: "folder-document-access-list-users" | |
description: "" | |
tuple_file: ./folder-document-access_tuples.json | |
list_users: | |
- object: folder:product-2021 | |
user_filter: | |
- type: user | |
assertions: | |
can_view: | |
users: | |
- user:anne | |
- user:beth | |
can_write: | |
users: | |
- user:anne | |
- name: "we can have mutliple tests per yaml file too. Not sure if my yaml syntax is 100% right though" | |
tuple_file: ./another-tuple-file.json | |
check: | |
- user: user:anne | |
object: folder:product-2021 | |
assertions: | |
can_view: true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: FolderBox | |
model_file: ./model.fga | |
tuple_file: ./model_tuples.yaml | |
test_files: | |
# Similar to how you interact with most test runners | |
# List out test files directly | |
- check.tests.yaml | |
- list_objects.tests.yaml | |
- list_users.tests.yaml | |
# Or maybe we could allow globbing | |
- ./*.tests.yaml # any files matching *.tests.yaml alongside this file | |
- ./**/*.tests.yaml # any files matching *.tests.yaml alongside and in child directories of this directory |
@Oscmage we don't support this structure yet, once we introduce it to the CLI then we'll definitely rework those testing and modular models guides to include a reference to this.
@aaguiarz We'd only support the fields listed here, I'm not sure if our parsing library errors or ignores unknown fields.
For running singular tests, we could (eventually) include something like a --filter
flag like most test runners have that only run tests where the name matches a string. Longer term as we look to add test support within the IDEs this is something we would need for sure
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The issue with this approach is that now I can't just run the test for one .fga.yaml (e.g. list_users.tests.yaml), and when I'm evolving the model or writing new tests that's probably what I want.