From 03d09a85dd66544baf8c1c885e81e11b06cbd31c Mon Sep 17 00:00:00 2001 From: Anurag Bandyopadhyay Date: Thu, 12 Jun 2025 11:32:04 +0530 Subject: [PATCH 1/4] feat: documentation changes for multiple tuple files support in tests this is linked to the changes proposed and introduced in https://github.com/openfga/cli/pull/506 --- docs/content/modeling/testing-models.mdx | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/docs/content/modeling/testing-models.mdx b/docs/content/modeling/testing-models.mdx index 7ded6c70a..81890612d 100644 --- a/docs/content/modeling/testing-models.mdx +++ b/docs/content/modeling/testing-models.mdx @@ -51,8 +51,18 @@ model: | current_time < grant_time + grant_duration } -# tuple_file: ./tuples.yaml # you can specify an external file, include it inline, or both -tuples: +# You can provide relationship tuples in one of the following ways: +# - As a single external file using 'tuple_file' +# - As multiple external files using 'tuple_files' +# - Inline directly using 'tuples' +# +# Examples: +# tuple_file: ./tuples.yaml # Single external file +# tuple_files: # Multiple external files +# - ./tuples_2.yaml +# - ./tuples_3.yaml +tuples: # Inline tuple definitions go here + # Anne is a member of the Acme organization - user: user:anne From cf252bf621cd173dda7b382106a0e5499deef8da Mon Sep 17 00:00:00 2001 From: Anurag Bandyopadhyay Date: Thu, 12 Jun 2025 12:56:30 +0530 Subject: [PATCH 2/4] feat: include tuple_files in all sections of doc --- docs/content/modeling/testing-models.mdx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/content/modeling/testing-models.mdx b/docs/content/modeling/testing-models.mdx index 81890612d..b5ad5804e 100644 --- a/docs/content/modeling/testing-models.mdx +++ b/docs/content/modeling/testing-models.mdx @@ -27,7 +27,7 @@ The `.fga.yaml` contains tests for model or a reference to an external model file in `fga`, `json` or `mod` format | -|`tuples or tuple_file` (optional) | A set of tuples or a reference to an external tuple file in `json`, `yaml` or `csv` format. These are considered for all tests. | +|`tuples or tuple_file or multiple tuple_files` (optional) | A set of tuples or a reference to an external tuple file in `json`, `yaml` or `csv` format. These are considered for all tests. | |`tests` | A set of tests that verify the return values of API calls | The example below defines a model and tuples: @@ -89,7 +89,7 @@ Tests have the following structure: | Object | Description | | -------- | -------- | |`name` (optional) | A descriptive name for the test, like “Organization Membership” | -|`tuple_file` or `tuples` | A set of tuples that are only considered for the test | +|`tuple_file` or `tuple_files` or `tuples` | A set of tuples that are only considered for the test | |`check` | A set of tests for Check calls, each with a user/object and a set of assertions | |`list_objects` | A set of tests for ListObjects calls, each one with a user/type and a set of assertions for any number of relations| |`list_users` | A set of tests for ListUsers calls, each one with an object and user filter and a set of assertions for the users for any number of relations | @@ -201,7 +201,7 @@ The example above checks that the `organization:acme`, given the current time is If you are using [Modular Models](./modular-models.mdx), you need to use the `fga.mod` as the `model_file`. -You can define the tests for each model in separate `.fga.yaml` files. All files should point to the `fga.mod` model. You can create a shared file with tuples and reference it with the `tuple_file` option. You can include module-specific tuples in each `fga.yaml` file. +You can define the tests for each model in separate `.fga.yaml` files. All files should point to the `fga.mod` model. You can create a shared file with tuples and reference it with the `tuple_file` option. You can also create multiple shared files with tuples and reference them using `tuple_files` option. You can include module-specific tuples in each `fga.yaml` file. ## Running tests From ee0e65d39fcd6d1d2fd88390066f90af7bc75ac3 Mon Sep 17 00:00:00 2001 From: Anurag Bandyopadhyay Date: Thu, 12 Jun 2025 12:58:18 +0530 Subject: [PATCH 3/4] feat: only code fmt the cmd obj --- docs/content/modeling/testing-models.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/content/modeling/testing-models.mdx b/docs/content/modeling/testing-models.mdx index b5ad5804e..213a6be0f 100644 --- a/docs/content/modeling/testing-models.mdx +++ b/docs/content/modeling/testing-models.mdx @@ -27,7 +27,7 @@ The `.fga.yaml` contains tests for model or a reference to an external model file in `fga`, `json` or `mod` format | -|`tuples or tuple_file or multiple tuple_files` (optional) | A set of tuples or a reference to an external tuple file in `json`, `yaml` or `csv` format. These are considered for all tests. | +|`tuples` or `tuple_file` or multiple `tuple_files` (optional) | A set of tuples or a reference to an external tuple file in `json`, `yaml` or `csv` format. These are considered for all tests. | |`tests` | A set of tests that verify the return values of API calls | The example below defines a model and tuples: From 84d2e616659753928ccaa813ffa7199d6f0a6167 Mon Sep 17 00:00:00 2001 From: Anurag Bandyopadhyay Date: Thu, 12 Jun 2025 14:35:50 +0530 Subject: [PATCH 4/4] feat: rephrase example comment --- docs/content/modeling/testing-models.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/content/modeling/testing-models.mdx b/docs/content/modeling/testing-models.mdx index 213a6be0f..e4bc607a0 100644 --- a/docs/content/modeling/testing-models.mdx +++ b/docs/content/modeling/testing-models.mdx @@ -201,7 +201,7 @@ The example above checks that the `organization:acme`, given the current time is If you are using [Modular Models](./modular-models.mdx), you need to use the `fga.mod` as the `model_file`. -You can define the tests for each model in separate `.fga.yaml` files. All files should point to the `fga.mod` model. You can create a shared file with tuples and reference it with the `tuple_file` option. You can also create multiple shared files with tuples and reference them using `tuple_files` option. You can include module-specific tuples in each `fga.yaml` file. +You can define tests for each model in separate `.fga.yaml` files, all of which should reference the common `fga.mod` model. Shared relationship tuples can be placed in a separate file and included using the `tuple_file` option. If needed, you can split tuples across multiple shared files and include them with the `tuple_files` option. Additionally, each `.fga.yaml` file can include module-specific tuples inline. ## Running tests