Skip to content

Conversation

@rhamzeh
Copy link
Member

@rhamzeh rhamzeh commented Jul 11, 2025

Description

This change allows users to:

  • Run tests with only tuples defined in tests
  • Run tests with only global tuples
  • Run specific tests as if no tuples exist
  • Run tests with tuples in the tests and globally

What problem is being solved?

How is it being solved?

What changes are made to solve it?

References

closes #539

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

Summary by CodeRabbit

  • Bug Fixes

    • Improved handling when no tuple files are provided; the system now loads zero tuples without reporting an error.
  • Tests

    • Updated test cases to expect zero tuples loaded (instead of an error) when no tuple files are specified.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 11, 2025

Walkthrough

The changes update the logic for loading tuples in the test store: tuple files are now only loaded if specified, and the absence of tuple files no longer results in an error. The related test is adjusted to expect zero tuples instead of an error when no tuple files are provided.

Changes

File(s) Change Summary
internal/storetest/storedata.go Removed unused error variable and updated tuple loading logic to only load from specified files, removing error on missing sources.
internal/storetest/storedata_test.go Updated test case to expect zero tuples instead of an error when no tuple files are provided.

Sequence Diagram(s)

sequenceDiagram
    participant TestRunner
    participant StoreData
    participant FileSystem

    TestRunner->>StoreData: LoadTuples()
    alt TupleFile is specified
        StoreData->>FileSystem: loadAndAddTuplesFromFile(TupleFile)
        FileSystem-->>StoreData: Tuples
    end
    alt TupleFiles is non-empty
        loop for each file in TupleFiles
            StoreData->>FileSystem: loadAndAddTuplesFromFile(file)
            FileSystem-->>StoreData: Tuples
        end
    end
    StoreData->>StoreData: loadTestTuples()
    StoreData-->>TestRunner: Loaded Tuples
Loading

Assessment against linked issues

Objective Addressed Explanation
Allow tuple files at the test level to satisfy validation (#540)
Test loading tuples when only a test-level tuple file is provided (#540)

Possibly related PRs

  • feat: support multiple tuple files #506: Expands tuple loading logic to support multiple tuple files with new fields and error handling, which relates to the tuple loading simplification in this PR.

Suggested reviewers

  • aaguiarz

📜 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 c2ce0c4 and 5b188a3.

📒 Files selected for processing (2)
  • internal/storetest/storedata.go (1 hunks)
  • internal/storetest/storedata_test.go (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
internal/storetest/storedata_test.go (1)
internal/storetest/storedata.go (1)
  • StoreData (81-89)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: Test Release Process
  • GitHub Check: Tests
  • GitHub Check: Lints
  • GitHub Check: Analyze (actions)
  • GitHub Check: Analyze (go)
🔇 Additional comments (2)
internal/storetest/storedata.go (1)

133-145: LGTM! Conditional tuple loading aligns perfectly with PR objectives.

The addition of conditional checks (if storeData.TupleFile != "" and if len(storeData.TupleFiles) > 0) successfully makes tuple files optional, which addresses the core issue of store tuples being mandatory. This allows users to:

  • Run tests with only tuples defined in tests
  • Run tests with only global tuples
  • Run specific tests as if no tuples exist

The implementation maintains backward compatibility while adding the desired flexibility.

internal/storetest/storedata_test.go (1)

48-51: LGTM! Test case correctly reflects the new optional tuple behavior.

The modification from expecting an error to expecting zero tuples (expectTuples: 0) perfectly aligns with the implementation changes. This test case now correctly validates that:

  • No tuple files provided is a valid scenario (no error)
  • Zero tuples are loaded when no files are specified

The test change is minimal and focused, maintaining good test coverage while supporting the new optional tuple functionality.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 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.

@rhamzeh rhamzeh force-pushed the fix/tuples-being-required branch from 53a9078 to 30a56cd Compare July 11, 2025 13:17
@rhamzeh rhamzeh force-pushed the fix/tuples-being-required branch from 30a56cd to 5b188a3 Compare July 11, 2025 13:17
@rhamzeh rhamzeh marked this pull request as ready for review July 11, 2025 13:17
@rhamzeh rhamzeh requested a review from a team as a code owner July 11, 2025 13:17
@rhamzeh rhamzeh requested a review from Copilot July 11, 2025 13:18
Copy link

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 relaxes the requirement that at least one tuples source must be provided to StoreData.LoadTuples, making tuple inputs fully optional and updating tests accordingly.

  • Removed the error when no tuple files or inline tuples are specified
  • Guard tuple-loading calls behind presence checks for TupleFile and TupleFiles
  • Updated the test case to expect zero tuples instead of an error when no sources are given

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
internal/storetest/storedata.go Removed mandatory-tuple error, added presence checks for loading
internal/storetest/storedata_test.go Changed test to assert zero tuples instead of an error
Comments suppressed due to low confidence (3)

internal/storetest/storedata_test.go:50

  • Ensure the test runner logic is updated to use expectTuples—assert that err is nil when expectTuples is defined and verify the loaded tuples count matches the expected value.
			expectTuples: 0,

internal/storetest/storedata.go:133

  • [nitpick] Consider validating that TupleFile and TupleFiles aren’t both set at once to avoid duplicate or conflicting loads. For example, return an error if both are provided.
	if storeData.TupleFile != "" {

internal/storetest/storedata.go:130

  • Update the function’s doc comment to reflect that tuples are now optional and no longer required, aligning the documentation with the new behavior.
		addTuples(storeData.Tuples)

@rhamzeh rhamzeh mentioned this pull request Jul 11, 2025
4 tasks
@rhamzeh rhamzeh added this pull request to the merge queue Jul 11, 2025
Merged via the queue into main with commit 64b66bd Jul 11, 2025
22 checks passed
@rhamzeh rhamzeh deleted the fix/tuples-being-required branch July 11, 2025 14:34
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.

Model tests cannot process tuple files anymore in 0.7.1

4 participants