openfga / cli

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

Clarify that tests are run locally when specifying a model .fga.yaml + store-id #335

Open aaguiarz opened 4 months ago

aaguiarz commented 4 months ago

When you run model test using a file that has a model and we specify the store-id, the store-id is ignored and tests are run locally on the CLI.

fga model test --tests store.fga.yaml --store-id 01HYX4FWK9P2VFRQ0YABYNQ447

I think that's the right behavior, but we should display a message clarifying it:

$ fga model test --tests store.fga.yaml --store-id 01HYX4FWK9P2VFRQ0YABYNQ447
Ignoring store-id parameter, running tests locally using model from store.fga.yaml

# Test Summary #
Tests 2/2 passing
Checks 4/4 passing

Note that if the fga.yaml file does NOT have a model, tests are run in the OpenFGA server.

yogendrav-flwls commented 4 months ago

Might be better to have a flag explicitly stating if we are running locally rather than coupling the store id as such

aaguiarz commented 4 months ago

@yogendrav-flwls thanks for the feedback!

If we had a parameter that forced running it in the server (e.g. --server), we'll need to either:

The behavior coul be to always run it locally by default and have a flag to run it in the server. If the flag is specified we ignore the model/tuples. If store-id is specified without the flag, we'd return an error.

Something like:

$ fga model test --tests store.fga.yaml --store-id 01HYX4FWK9P2VFRQ0YABYNQ447
Please specify the --server option to run the tests on the FGA server

$ fga model test --tests store.fga.yaml --store-id 01HYX4FWK9P2VFRQ0YABYNQ447 --server
Ignoring model + tuples, running tests on the FGA server 

# Test Summary #
Tests 2/2 passing
Checks 4/4 passing

Would that make sense?