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

feat(test): support referenvcing a tuple_file instead of tuples #212

Merged
merged 2 commits into from
Jan 5, 2024

Conversation

ewanharris
Copy link
Member

Description

Adds support for using tuple_file instead of tuples in a test file. The file can be either a yaml or json syntax. All tuple files are loaded upfront before running tests so that we can ensure that the test run will be functional and all errors are collated and presented to the user like below.

fga model test --tests ./example/model.fga.yaml
Error: error running tests due to failed to process one or more tuple files
failed to process global tuple ./model_tuples.yaml file due to yaml: line 7: could not find expected ':'
failed to process tuple file ./folder-document-access_tuple.json for test folder-document-access due to open example/folder-document-access_tuple.json: no such file or directory
exit status 1

The model.fga.yaml example has been updated to show this and also demonstrate the two file types that are supported.

References

Closes #179

Review Checklist

  • I have clicked on "allow edits by maintainers".
  • I have added documentation for new/changed functionality in this PR or in a PR to openfga.dev [Provide a link to any relevant PRs in the references section above]
  • The correct base branch is being used, if not main
  • I have added tests to validate that the change in functionality is working as expected

@ewanharris ewanharris requested a review from a team as a code owner January 5, 2024 14:24
@ewanharris ewanharris force-pushed the feat/179-allow-tuple_file branch from 5932a95 to 19281ff Compare January 5, 2024 14:26
internal/storetest/storedata.go Show resolved Hide resolved
@ewanharris ewanharris added this pull request to the merge queue Jan 5, 2024
@rhamzeh rhamzeh changed the title feat(test): support tuple_file instead of tuples feat(test): support tuple_file alongside of tuples Jan 5, 2024
@rhamzeh rhamzeh changed the title feat(test): support tuple_file alongside of tuples feat(test): support referenvcing a tuple_file instead of tuples Jan 5, 2024
Merged via the queue into main with commit 40cdeaf Jan 5, 2024
12 checks passed
@ewanharris ewanharris deleted the feat/179-allow-tuple_file branch January 5, 2024 14:52
@@ -43,6 +50,7 @@ type ModelTest struct {
Name string `json:"name" yaml:"name"`
Description string `json:"description" yaml:"description"`
Tuples []client.ClientContextualTupleKey `json:"tuples" yaml:"tuples"`
TupleFile string `json:"tuple_file" yaml:"tuple_file"` //nolint:tagliatelle
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would a more appropriate name for this have been TuplesFile ? 🤔

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I considered that as it will most likely always contain multiple tuples but I wasn't entirely sold on it, happy to PR changing it if there's consensus for that

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rhamzeh given that you filed the initial issue what do you think about ☝🏻 , I also just noticed that the vscode extension does perform validation for a tuples_file property here so not sure if that should be considered in this addition (but I can't see any usage of it within the extension).

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

Successfully merging this pull request may close these issues.

Allow for a tuple_file option in the store file format
3 participants