openfga / cli

A cross-platform CLI to interact with an OpenFGA server
https://openfga.dev
Apache License 2.0
50 stars 25 forks source link

Use Relative Path in `model_file` in Tests #349

Open RichardWhitfield opened 5 months ago

RichardWhitfield commented 5 months ago

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:

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.

Denis-Kuso commented 3 weeks ago

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

aaguiarz commented 3 weeks ago

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

Denis-Kuso commented 2 weeks ago

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:

2 directories, 4 files


- renamed the location of model files as described in the issue, i.e. relative
to the test file

```bash
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

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