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

Use Relative Path in model_file in Tests #349

Open
RichardWhitfield opened this issue Jun 17, 2024 · 3 comments
Open

Use Relative Path in model_file in Tests #349

RichardWhitfield opened this issue Jun 17, 2024 · 3 comments
Assignees
Labels
good first issue Good for newcomers help wanted Extra attention is needed

Comments

@RichardWhitfield
Copy link

When defining the location of the model_file in a test yaml file, the expected behaviour is that the path to the model_file is relative to the test file where it is referenced but seems to be relative to the directory where the command originated.

For example: I have a folder structure as below:

  • src
    • schema.fga
  • tests
    • tests.yaml
    • data.yaml

In my tests.yaml file I define the location of the model_file as ../src/schema.fga.

If I execute this command:
fga model test --tests .\tests\tests.fga.yaml
from the root directory of the repo I get the below error:
Error: failed to read file ../src/schema.fga due to open ../src/schema.fga: The system cannot find the path specified.

If I execute the similar command:
fga model test --tests .\tests.fga.yaml then the command successfully executes.

@aaguiarz aaguiarz added good first issue Good for newcomers help wanted Extra attention is needed labels Sep 25, 2024
@Denis-Kuso
Copy link

Hi! I’m interested in taking on this issue. Can I go ahead and work on it?

@aaguiarz
Copy link
Member

aaguiarz commented Nov 4, 2024

Yes, I'm assigning it to you! Thanks!

@aaguiarz aaguiarz assigned aaguiarz and Denis-Kuso and unassigned aaguiarz Nov 4, 2024
@Denis-Kuso
Copy link

Subject: Issue with CLI behavior – Unable to reproduce

Hi @aaguiarz ,

I’ve tested the issue by forking the repository, building and running the CLI as described.
After reproducing the steps in a clean environment, I found that the behavior
aligns with the expected output and the issue appears to be non-existent.

Here are the details I tested:

  • downloaded your sample data with git clone https://github.com/openfga/sample-stores.git openfga-sample-stores
  • reproduced the directory structure in the issue using your sample data (see below)
tree
.
├── src
│   ├── github.model.fga
│   └── model.fga
└── tests
    ├── github.store.fga.yaml
    └── store.fga.yaml

2 directories, 4 files
  • renamed the location of model files as described in the issue, i.e. relative
    to the test file
grep "model_file" tests/store.fga.yaml
model_file: ../src/model.fga
grep "model_file" tests/github.store.fga.yaml
model_file: ../src/github.model.fga
  • ran the command as described in the issue (ran multiple times from different locations
    showing only two different files as examples)

  • first example of expected/desired behaviour (works)

fga model test --tests ./tests/store.fga.yaml
# Test Summary #
Tests 3/3 passing
Checks 6/6 passing
ListObjects 1/1 passing
ListUsers 1/1 passing
  • second example of expected/desired behaviour (works)
fga model test --tests ./tests/github.store.fga.yaml
# Test Summary #
Tests 4/4 passing
Checks 6/6 passing
ListObjects 1/1 passing
ListUsers 3/3 passing
  • undesired behaviour (get error as expected)
fga model test --tests ./store.fga.yaml
Error: failed to read file ./store.fga.yaml due to open ./store.fga.yaml: no such file or directory

Please let me know if I misunderstood the issue or perhaps
if there’s any additional context I should be aware of.

Best regards,

Denis

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Extra attention is needed
Projects
Status: Backlog
Development

No branches or pull requests

3 participants