Skip to content

Conversation

aaguiarz
Copy link
Member

@aaguiarz aaguiarz commented Jun 9, 2025

Summary

  • add users and objects list field to ModelTestCheck for store tests
  • run store check tests for all listed users and objects
  • handle multi-user / multi-object assertions on import
  • document the new users/object list syntax in README
  • test importing/exporting stores containing checks with multiple users/objects. The tests are imported as individual assertions, so the grouping is lost on the import/export flow.

Testing

  • make test-unit

https://chatgpt.com/codex/tasks/task_e_6846fd0c3ad0832298cc760e9adbbe8d

Summary by CodeRabbit

  • New Features
    • Added support for defining and validating test cases with multiple users and/or multiple objects in permission checks.
  • Bug Fixes
    • Improved validation to ensure only one of single or multiple users/objects can be specified in a test case.
  • Documentation
    • Updated README and example files to illustrate how to use multiple users and objects in test definitions.
  • Tests
    • Added and expanded test cases to cover scenarios with multiple users and objects in permission checks.

@aaguiarz aaguiarz requested review from a team as code owners June 9, 2025 15:36
@aaguiarz
Copy link
Member Author

aaguiarz commented Jun 9, 2025

  • Built/tested this and worked fine.
  • We'll need to add support in VS code/Jetbrains to validate this new format.

@aaguiarz aaguiarz requested a review from Copilot June 9, 2025 21:22
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces support for group user checks in store tests by adding a new "Users" field to the ModelTestCheck struct and adjusting related test functions and import logic. Key changes include:

  • Adding a "Users" field to ModelTestCheck for multi-user assertions.
  • Updating remote and local test functions to iterate over multiple users when provided.
  • Extending the import and README documentation to demonstrate multi-user syntax in store tests.

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
internal/storetest/storedata.go Added new "Users" field in ModelTestCheck
internal/storetest/remotetest.go Modified remote check test logic to handle multiple users
internal/storetest/localtest.go Modified local check test logic to handle multiple users
cmd/store/import_test.go Updated tests to include multi-user assertions
cmd/store/import.go Revised user handling in check assertions extraction
README.md Documented new multi-user checks syntax

@aaguiarz
Copy link
Member Author

@coderabbitai review

Copy link
Contributor

coderabbitai bot commented Jun 13, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Contributor

coderabbitai bot commented Jun 13, 2025

Walkthrough

The changes enhance OpenFGA CLI test definitions and processing to support multiple users and multiple objects per check. Documentation and examples illustrate this new capability. Core logic, test runners, and validation functions are updated to handle and enforce correct usage of singular versus plural user and object fields in test assertions.

Changes

File(s) Change Summary
README.md, example/model.fga.yaml Documentation and examples updated to demonstrate checks with multiple users and objects, clarifying YAML schema usage.
example/model.fga, example/folder-document-access_tuples.json can_view relation in document expanded to include direct [user]; one access tuple entry removed.
cmd/store/import.go, internal/storetest/localtest.go, internal/storetest/remotetest.go, internal/storetest/utils.go Logic modified to support multiple users and objects per check; utility functions added for consistent retrieval of users/objects.
internal/storetest/storedata.go ModelTestCheck struct extended with Users and Objects slices; validation method added to enforce exclusive use of singular/plural fields.
internal/storetest/storedata_test.go Added tests for StoreData.Validate method and struct tag behavior for single vs. multiple users/objects fields.
cmd/store/import_test.go Added test cases for multi-user and multi-object assertions; test logic updated to select expected assertions accordingly.
internal/storetest/read-from-input.go, internal/storetest/tests.go Added validation step calling Validate() before processing store data or running tests.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant CLI
    participant StoreData
    participant Validator
    participant TestRunner

    User->>CLI: Provide test YAML with multiple users/objects
    CLI->>StoreData: Parse YAML
    StoreData->>Validator: Validate single/multi user/object fields
    Validator-->>StoreData: Return validation result
    StoreData-->>CLI: Return parsed and validated data
    CLI->>TestRunner: Run checks for all user-object combinations
    TestRunner->>StoreData: Get effective users/objects
    loop For each user-object pair
        TestRunner->>CLI: Run check/assertion
    end
    CLI-->>User: Output test results
Loading

Poem

In fields of YAML, rabbits hop,
Now users and objects—more than one—won't stop!
Docs and tests all spruced anew,
Checks for many, not just a few.
With tuples pruned and logic tight,
This bunny codes through day and night!
🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0044a63 and 2d7580a.

📒 Files selected for processing (1)
  • README.md (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • README.md
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Test Release Process
  • GitHub Check: Tests
  • GitHub Check: Analyze (go)

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🔭 Outside diff range comments (1)
internal/storetest/storedata.go (1)

32-38: 🛠️ Refactor suggestion

Ambiguity when both User and Users are populated

All call-sites treat Users as authoritative when non-empty, silently ignoring User. Accidentally filling in both fields will therefore drop the single user without warning.
Consider validating the struct at read time to guarantee mutual exclusivity, e.g.:

func (c ModelTestCheck) EffectiveUsers() ([]string, error) {
    if len(c.Users) > 0 && c.User != "" {
-       // silently prefer Users today
+       return nil, fmt.Errorf("both 'user' and 'users' are set – choose one")
    }
    if len(c.Users) > 0 {
        return c.Users, nil
    }
    return []string{c.User}, nil
}

Centralising the “effective users” logic also removes the duplication noted in other files.

♻️ Duplicate comments (3)
cmd/store/import.go (1)

235-238: Same ‘effective users’ logic duplicated across 3 files
This was already flagged in previous reviews – extracting a helper (e.g. checkTest.EffectiveUsers()) avoids drift.

internal/storetest/remotetest.go (1)

37-41: Shared logic – please extract helper
Same comment as before: users := … / fallback to single user appears in localtest.go, remotetest.go, and import.go. One helper on ModelTestCheck will keep behaviour consistent.

internal/storetest/localtest.go (1)

28-33: Extract duplicated “effective users” logic into a helper

The same users := ... ; if len(checkTest.Users) > 0 { … } pattern now appears in both local and remote test runners (see previous review). Centralising this in a small helper (e.g. getEffectiveUsers(single string, multi []string) []string) removes duplication, keeps precedence rules in one place and prevents drift.

🧹 Nitpick comments (3)
cmd/store/import.go (1)

240-249: Minor optimisation – pre-allocate slice

If a check has many relations and many users the inner append may trigger multiple reallocations. Pre-allocating once per check is cheap and removes that cost:

-    for _, user := range users {
-        for relation, expectation := range checkTest.Assertions {
-            assertions = append(assertions, client.ClientAssertion{
+    for _, user := range users {
+        for relation, expectation := range checkTest.Assertions {
+            assertions = append(assertions, client.ClientAssertion{
                 User:        user,
                 Relation:    relation,
                 Object:      checkTest.Object,
                 Expectation: expectation,
             })
-        }
+        }
     }

Not critical but easy to include.

cmd/store/import_test.go (1)

148-155: Hard-coding expected assertions based on test case name couples data & control

Instead of branching on the string literal, include the expected assertions inside each table entry:

-        mockWriteAssertions: true,
-        ...
-        testStore: …,
+        mockWriteAssertions: true,
+        expected: multiUserAssertions,
+        testStore: …,

and use that directly in the setup helper. Reduces indirection and makes adding new cases trivial.

internal/storetest/localtest.go (1)

47-55: Avoid repeated context marshaling

structpb.NewStruct(*checkTest.Context) is invoked once per (user, relation) pair even though the context is identical for all of them. Moving the conversion outside both loops (or caching ctx after the first conversion) would save work and simplify error handling.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 296eca9 and 66564cf.

📒 Files selected for processing (6)
  • README.md (2 hunks)
  • cmd/store/import.go (1 hunks)
  • cmd/store/import_test.go (4 hunks)
  • internal/storetest/localtest.go (1 hunks)
  • internal/storetest/remotetest.go (1 hunks)
  • internal/storetest/storedata.go (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
cmd/store/import_test.go (1)
internal/storetest/storedata.go (3)
  • StoreData (68-75)
  • ModelTest (58-66)
  • ModelTestCheck (32-38)
🔇 Additional comments (1)
internal/storetest/remotetest.go (1)

42-56: Potential large-fan-out loop

The nested loops generate len(users) * len(assertions) remote calls. For big test sets you may want to cap or parallelise them to keep test time reasonable.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
internal/storetest/utils.go (2)

4-5: Return a defensive copy of the slice
checkTest.Users is returned directly, so any caller that appends/modifies the slice mutates the same backing array captured in the copied struct. This can create non-obvious test coupling. A trivial, allocation-cheap fix:

-        return checkTest.Users
+        return append([]string(nil), checkTest.Users...)

3-3: Minor: accept pointer to avoid unnecessary struct copy
ModelTestCheck carries several fields (maps, slices). Passing it by value copies the slice/map headers each call; passing *ModelTestCheck avoids this and signals immutability intent. Low impact but worth considering.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1357c92 and a645ae0.

📒 Files selected for processing (4)
  • cmd/store/import.go (1 hunks)
  • internal/storetest/localtest.go (1 hunks)
  • internal/storetest/remotetest.go (1 hunks)
  • internal/storetest/utils.go (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • internal/storetest/remotetest.go
  • internal/storetest/localtest.go
  • cmd/store/import.go
🧰 Additional context used
🧬 Code Graph Analysis (1)
internal/storetest/utils.go (1)
internal/storetest/storedata.go (1)
  • ModelTestCheck (32-38)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Tests
🔇 Additional comments (1)
internal/storetest/utils.go (1)

3-9: Guard against empty “user(s)” definition to avoid downstream panics
If a ModelTestCheck arrives with both Users and User unset / empty, the function will silently return []string{""}.
Any caller that iterates over this result and uses the value as a principal ID will likely produce confusing authorization errors or panics further away from the root-cause. Consider returning nil + an error (or at least logging) when neither field is populated.

@aaguiarz
Copy link
Member Author

Let's:

  • Return an error if both user and users are specified
  • Add the same behavior for object

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🔭 Outside diff range comments (1)
internal/storetest/read-from-input.go (1)

34-40: Close the opened file to avoid descriptor leaks

os.Open leaves the descriptor open for the lifetime of the process if Close is never called.
Add a defer testFile.Close() immediately after the error check to ensure resources are released even on early returns.

 testFile, err := os.Open(fileName)
 if err != nil {
     return format, nil, fmt.Errorf("failed to read file %s due to %w", fileName, err)
 }
+defer testFile.Close() // always close the file handle
🧹 Nitpick comments (3)
internal/storetest/read-from-input.go (1)

57-60: Validation already happens again in RunTests – minor duplication

storeData.Validate() is also invoked at the top of RunTests.
Running it here is harmless but redundant; if the method ever becomes expensive, this double-call could be avoided by trusting the caller or documenting the expectation.

No action required now, just flagging for awareness.

internal/storetest/tests.go (1)

39-42: Second call to Validate() – consider consolidating responsibility

RunTests performs its own validation, but ReadFromFile already does so.
If every consumer comes through ReadFromFile, you can drop this call.
Conversely, if callers may construct StoreData programmatically, leave it here and document that RunTests must receive validated data.

Your call – just ensure the contract is explicit.

internal/storetest/storedata_test.go (1)

10-32: Split into named sub-tests for clearer failure output

All four scenarios run in the same function; when one fails, it’s harder to see which.
Using t.Run gives granular reporting and keeps the table extensible.

-func TestStoreDataValidate(t *testing.T) {
-    t.Parallel()
-
-    validSingle := ...
-    assert.NoError(t, validSingle.Validate())
-
-    validUsers := ...
-    assert.NoError(t, validUsers.Validate())
-
-    invalidBoth := ...
-    require.Error(t, invalidBoth.Validate())
-
-    invalidNone := ...
-    require.Error(t, invalidNone.Validate())
-}
+func TestStoreDataValidate(t *testing.T) {
+    t.Parallel()
+
+    cases := []struct {
+        name    string
+        data    StoreData
+        wantErr bool
+    }{
+        {"single user", validSingle, false},
+        {"multiple users", validUsers, false},
+        {"both fields", invalidBoth, true},
+        {"no user fields", invalidNone, true},
+    }
+
+    for _, tc := range cases {
+        tc := tc
+        t.Run(tc.name, func(t *testing.T) {
+            if tc.wantErr {
+                require.Error(t, tc.data.Validate())
+            } else {
+                assert.NoError(t, tc.data.Validate())
+            }
+        })
+    }
+}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e762df2 and 6ea62b0.

📒 Files selected for processing (6)
  • README.md (2 hunks)
  • cmd/store/import.go (2 hunks)
  • internal/storetest/read-from-input.go (1 hunks)
  • internal/storetest/storedata.go (2 hunks)
  • internal/storetest/storedata_test.go (1 hunks)
  • internal/storetest/tests.go (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • internal/storetest/storedata.go
  • cmd/store/import.go
  • README.md
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Test Release Process
  • GitHub Check: Tests

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
internal/storetest/remotetest.go (1)

40-56: Minor perf tweak – pre-allocate results slice
With nested loops over users, objects, and assertions, the slice can grow rapidly. Pre-computing its capacity prevents multiple re-allocations and marginally speeds large test suites.

-	results := []ModelTestCheckSingleResult{}
+	capacity := len(users) * len(objects) * len(checkTest.Assertions)
+	results := make([]ModelTestCheckSingleResult, 0, capacity)
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6ea62b0 and d24c680.

📒 Files selected for processing (8)
  • README.md (2 hunks)
  • cmd/store/import.go (2 hunks)
  • cmd/store/import_test.go (4 hunks)
  • internal/storetest/localtest.go (1 hunks)
  • internal/storetest/remotetest.go (1 hunks)
  • internal/storetest/storedata.go (2 hunks)
  • internal/storetest/storedata_test.go (1 hunks)
  • internal/storetest/utils.go (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (6)
  • internal/storetest/storedata_test.go
  • cmd/store/import_test.go
  • internal/storetest/localtest.go
  • README.md
  • internal/storetest/storedata.go
  • cmd/store/import.go
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Tests
🔇 Additional comments (3)
internal/storetest/remotetest.go (1)

37-39: Good move: shared helper eliminates duplicated logic
Switching to GetEffectiveUsers / GetEffectiveObjects centralises the singular-vs-plural handling that was repeated across runners. This clearly addresses the earlier duplication comment and improves maintainability.

internal/storetest/utils.go (2)

3-9: I’d like to inspect the ModelTestCheck definition and how GetEffectiveUsers is used to confirm whether guarding against an empty User and returning a copy makes sense.

#!/bin/bash
# Find the ModelTestCheck struct definition
rg "type ModelTestCheck" -A5

# Find all call sites of GetEffectiveUsers
rg "GetEffectiveUsers" -n -A3

11-17: Let’s inspect the full definition of ModelTestCheck to confirm the presence and order of its fields:

#!/bin/bash
# Show full struct definition of ModelTestCheck
rg -n 'type ModelTestCheck struct' -A20 internal/storetest/storedata.go

@aaguiarz aaguiarz requested a review from rhamzeh June 19, 2025 00:59
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (2)
example/model.fga.yaml (2)

51-59: LGTM: Excellent demonstration of multi-entity testing

The new test case effectively demonstrates the users and objects functionality, testing multiple entities with a single assertion block. However, please fix the trailing spaces.

Remove trailing spaces:

         assertions:
           can_view: true
-          can_write: true          
+          can_write: true

83-83: Remove trailing whitespace

-          
+
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d24c680 and 55d1d41.

📒 Files selected for processing (5)
  • example/folder-document-access_tuples.json (0 hunks)
  • example/model.fga (1 hunks)
  • example/model.fga.yaml (2 hunks)
  • example/school.yaml (1 hunks)
  • internal/storetest/storedata.go (2 hunks)
💤 Files with no reviewable changes (1)
  • example/folder-document-access_tuples.json
🧰 Additional context used
🪛 YAMLlint (1.37.1)
example/model.fga.yaml

[error] 58-58: trailing spaces

(trailing-spaces)


[error] 83-83: trailing spaces

(trailing-spaces)

example/school.yaml

[warning] 1-1: too many blank lines

(1 > 0) (empty-lines)


[error] 3-3: trailing spaces

(trailing-spaces)


[error] 13-13: trailing spaces

(trailing-spaces)


[error] 47-47: trailing spaces

(trailing-spaces)


[warning] 51-51: wrong indentation: expected 10 but found 8

(indentation)


[warning] 54-54: wrong indentation: expected 14 but found 12

(indentation)


[warning] 54-54: too many spaces before colon

(colons)


[error] 55-55: trailing spaces

(trailing-spaces)


[warning] 59-59: wrong indentation: expected 14 but found 12

(indentation)


[warning] 59-59: too many spaces before colon

(colons)


[warning] 64-64: wrong indentation: expected 14 but found 12

(indentation)


[warning] 64-64: too many spaces before colon

(colons)


[warning] 69-69: wrong indentation: expected 14 but found 12

(indentation)


[warning] 69-69: too many spaces before colon

(colons)


[warning] 74-74: wrong indentation: expected 14 but found 12

(indentation)


[warning] 74-74: too many spaces before colon

(colons)


[error] 74-74: no new line character at the end of file

(new-line-at-end-of-file)

🪛 GitHub Check: Lints
internal/storetest/storedata.go

[failure] 160-160:
do not define dynamic errors, use wrapped static errors instead: "fmt.Errorf("%s", msg)" (err113)


[failure] 155-155:
do not define dynamic errors, use wrapped static errors instead: "fmt.Errorf("%s", msg)" (err113)


[failure] 152-152:
do not define dynamic errors, use wrapped static errors instead: "fmt.Errorf("%s", msg)" (err113)

⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Test Release Process
  • GitHub Check: Tests
🔇 Additional comments (2)
example/model.fga (1)

24-24: LGTM: Enhanced document access permissions

The addition of [user] to the can_view relation broadens document access permissions appropriately, supporting the multi-user testing framework while maintaining existing viewer-based access patterns.

internal/storetest/storedata.go (1)

35-37: LGTM: Well-designed extension for multi-entity support

The addition of Users and Objects fields enables the multi-user and multi-object testing capabilities while maintaining backward compatibility with existing singular field usage.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

♻️ Duplicate comments (1)
internal/storetest/storedata.go (1)

144-173: Fix dynamic error creation to use static errors.

This issue was already flagged in previous reviews. The validation logic correctly enforces mutual exclusivity, but the error creation should use static errors instead of dynamic ones to follow Go best practices.

Please refer to the previous review comment which provided a comprehensive solution using static error variables.

🧹 Nitpick comments (1)
internal/storetest/storedata.go (1)

34-37: Fix struct tag alignment for consistency.

The struct tags are not aligned consistently, affecting code readability.

Apply this diff to align the tags:

-	User       string                  `json:"user,omitempty"       yaml:"user,omitempty"`
-	Users      []string                `json:"users,omitempty"      yaml:"users,omitempty"`
-	Object     string                  `json:"object,omitempty"     yaml:"object,omitempty"`
-	Objects    []string                `json:"objects,omitempty"    yaml:"objects,omitempty"`
+	User       string                  `json:"user,omitempty"    yaml:"user,omitempty"`
+	Users      []string                `json:"users,omitempty"   yaml:"users,omitempty"`
+	Object     string                  `json:"object,omitempty"  yaml:"object,omitempty"`
+	Objects    []string                `json:"objects,omitempty" yaml:"objects,omitempty"`
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 55d1d41 and 6b03abe.

📒 Files selected for processing (2)
  • internal/storetest/storedata.go (2 hunks)
  • internal/storetest/storedata_test.go (1 hunks)
🧰 Additional context used
🪛 GitHub Check: Lints
internal/storetest/storedata.go

[failure] 37-37:
tag is not aligned, should be: json:"objects,omitempty" yaml:"objects,omitempty" (tagalign)


[failure] 36-36:
tag is not aligned, should be: json:"object,omitempty" yaml:"object,omitempty" (tagalign)


[failure] 35-35:
tag is not aligned, should be: json:"users,omitempty" yaml:"users,omitempty" (tagalign)


[failure] 34-34:
tag is not aligned, should be: json:"user,omitempty" yaml:"user,omitempty" (tagalign)


[failure] 160-160:
do not define dynamic errors, use wrapped static errors instead: "fmt.Errorf("%s", msg)" (err113)


[failure] 155-155:
do not define dynamic errors, use wrapped static errors instead: "fmt.Errorf("%s", msg)" (err113)


[failure] 152-152:
do not define dynamic errors, use wrapped static errors instead: "fmt.Errorf("%s", msg)" (err113)

internal/storetest/storedata_test.go

[failure] 8-8:
import 'gopkg.in/yaml.v3' is not allowed from list 'test' (depguard)

⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Test Release Process
  • GitHub Check: Tests
  • GitHub Check: Analyze (go)
🔇 Additional comments (3)
internal/storetest/storedata_test.go (3)

11-43: Excellent test coverage for validation logic.

The test comprehensively covers all validation scenarios including valid configurations (single user/object, multiple users, multiple objects) and invalid configurations (conflicting fields, missing required fields).


45-153: Thorough testing of YAML marshaling behavior.

The test effectively verifies that the omitempty tags work correctly for all field combinations and ensures empty fields are properly omitted from YAML output.


8-8: I’ll re-run the search more precisely to locate the GolangCI config and extract any depguard rules:

#!/bin/bash
# Locate GolangCI configuration files
echo "GolangCI config files:"
fd ".golangci.*" -t f

# Extract depguard settings from them
echo -e "\nDepguard rules:"
fd ".golangci.*" -t f --exec rg -n "depguard" {} \;

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
example/model.fga.yaml (2)

57-57: Remove trailing spaces.

Static analysis detected trailing spaces on this line.

-          can_write: true          
+          can_write: true

81-81: Remove trailing spaces.

Static analysis detected trailing spaces on this line.

-          
+
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6b03abe and 08ea0e8.

📒 Files selected for processing (3)
  • example/model.fga.yaml (2 hunks)
  • internal/storetest/storedata.go (2 hunks)
  • internal/storetest/storedata_test.go (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • internal/storetest/storedata.go
🧰 Additional context used
🪛 YAMLlint (1.37.1)
example/model.fga.yaml

[error] 57-57: trailing spaces

(trailing-spaces)


[error] 81-81: trailing spaces

(trailing-spaces)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Test Release Process
🔇 Additional comments (3)
example/model.fga.yaml (1)

50-57: LGTM! New group user check syntax demonstrated correctly.

The new test case properly demonstrates the users and objects array syntax for group checks, which aligns with the PR objectives to support multiple users and objects in a single test assertion.

internal/storetest/storedata_test.go (2)

10-42: Excellent comprehensive validation test coverage.

The TestStoreDataValidate function thoroughly covers all the validation scenarios:

  • Valid single user/object configurations
  • Valid multiple users/objects configurations
  • Invalid combinations (both single and multiple fields set)
  • Missing required fields

This aligns perfectly with the PR objectives to enforce mutual exclusivity between singular and plural user/object fields.


44-78: Well-structured struct field behavior tests.

The TestModelTestCheckStructTagsOmitEmpty function effectively validates:

  • Proper handling of single vs. multiple user/object fields
  • Correct struct field assignments and empty states
  • Array length validation for multiple users/objects

The test cases provide good coverage for the new struct field behavior and demonstrate the expected omitempty behavior.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
example/model.fga.yaml (2)

55-58: Clarify assertion coverage for generated combinations.
Add a brief comment here to note that the assertions block applies to all user‐object pairs produced by the cross product of the two lists. This will improve readability for someone unfamiliar with the new syntax.


81-81: Remove trailing whitespace.
yamllint flags a trailing space on this blank line—please delete it to keep the file clean.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 08ea0e8 and 7403288.

📒 Files selected for processing (1)
  • example/model.fga.yaml (2 hunks)
🧰 Additional context used
🪛 YAMLlint (1.37.1)
example/model.fga.yaml

[error] 81-81: trailing spaces

(trailing-spaces)

⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Test Release Process
  • GitHub Check: Tests
  • GitHub Check: Analyze (go)
🔇 Additional comments (1)
example/model.fga.yaml (1)

50-54: Validate multi-field syntax consistency.
This example introduces the new users and objects keys in a single check. Confirm that:

  • Each entry in users follows the same “user:‹id›” format as the singular user field.
  • Each entry in objects matches the expected identifier format.
  • The implementation enforces mutual exclusivity between user vs. users and object vs. objects.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
example/model.fga.yaml (2)

50-57: Remove trailing whitespace in comment
Static analysis flagged a trailing space at the end of the comment line.

--- a/example/model.fga.yaml
+++ b/example/model.fga.yaml
@@ line 55
-          # These assertions are run for each user 
+          # These assertions are run for each user

58-65: Remove trailing whitespace in list and assertion value
Static analysis flagged trailing spaces at the end of the user mapping and the can_write value.

--- a/example/model.fga.yaml
+++ b/example/model.fga.yaml
@@ line 58
-      - user: user:anne 
+      - user: user:anne
@@ line 65
-          can_write: true           
+          can_write: true
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7403288 and 90e9dd8.

📒 Files selected for processing (1)
  • example/model.fga.yaml (2 hunks)
🧰 Additional context used
🪛 YAMLlint (1.37.1)
example/model.fga.yaml

[error] 55-55: trailing spaces

(trailing-spaces)


[error] 58-58: trailing spaces

(trailing-spaces)


[error] 65-65: trailing spaces

(trailing-spaces)

⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Tests
  • GitHub Check: Test Release Process
🔇 Additional comments (1)
example/model.fga.yaml (1)

66-75: Multi-user and multi-object assertions look correct
The combined users and objects block is properly structured and requires no changes.

@aaguiarz aaguiarz changed the title Support group user checks in store tests Support group user/object checks in store tests Jun 20, 2025
@rhamzeh rhamzeh changed the title Support group user/object checks in store tests feat: support group user/object checks in store tests Jun 26, 2025
@rhamzeh rhamzeh changed the title feat: support group user/object checks in store tests feat: support grouping user/object checks in store tests Jun 26, 2025
@rhamzeh rhamzeh enabled auto-merge June 26, 2025 22:52
@aaguiarz aaguiarz requested a review from Siddhant-K-code June 26, 2025 23:03
@rhamzeh rhamzeh added this pull request to the merge queue Jun 27, 2025
Merged via the queue into main with commit 9d7b6c4 Jun 27, 2025
22 checks passed
@rhamzeh rhamzeh deleted the codex/add-support-for-user-list-syntax-in-store-tests branch June 27, 2025 04:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants