diff --git a/cmd/model/test.go b/cmd/model/test.go index 4226c464..70ac232d 100644 --- a/cmd/model/test.go +++ b/cmd/model/test.go @@ -19,7 +19,6 @@ package model import ( "fmt" "os" - "path" "path/filepath" "strings" @@ -77,7 +76,7 @@ var modelTestCmd = &cobra.Command{ summaries := []string{} for _, file := range fileNames { - format, storeData, err := storetest.ReadFromFile(file, path.Dir(file)) + format, storeData, err := storetest.ReadFromFile(file, "") if err != nil { return fmt.Errorf("failed to read test file %s: %w", file, err) } diff --git a/tests/fixtures/relative-path/relative-path-store.fga.yaml b/tests/fixtures/relative-path/relative-path-store.fga.yaml new file mode 100644 index 00000000..08236db4 --- /dev/null +++ b/tests/fixtures/relative-path/relative-path-store.fga.yaml @@ -0,0 +1,10 @@ +name: Relative Path Store +model_file: ../basic-model.fga +tuple_file: ../basic-tuples.json +tests: + - name: test-1 + check: + - user: user:anne + object: group:foo + assertions: + owner: true \ No newline at end of file diff --git a/tests/import-tests-cases.yaml b/tests/import-tests-cases.yaml index 565054b2..42be315e 100644 --- a/tests/import-tests-cases.yaml +++ b/tests/import-tests-cases.yaml @@ -8,3 +8,9 @@ tests: stdout: json: store.name: "Basic Store" + 002 - it successfully imports a store with relative paths: + command: fga store import --file=./tests/fixtures/relative-path/relative-path-store.fga.yaml + exit-code: 0 + stdout: + json: + store.name: "Relative Path Store" diff --git a/tests/model-test-cases.yaml b/tests/model-test-cases.yaml new file mode 100644 index 00000000..c830cf4d --- /dev/null +++ b/tests/model-test-cases.yaml @@ -0,0 +1,20 @@ +config: + inherit-env: true + +tests: + 001 - it successfully runs local tests against a store with an absolute path: + command: fga model test --tests ./tests/fixtures/basic-store.fga.yaml + exit-code: 0 + stderr: # Test Summary # + 002 - it successfully runs local tests against a store with a relative path: + command: fga model test --tests tests/fixtures/basic-store.fga.yaml + exit-code: 0 + stderr: # Test Summary # + 003 - it successfully runs local tests against a store when resolving a glob pattern: + command: fga model test --tests "tests/**/*-store.fga.yaml" + exit-code: 0 + stderr: # Test Summary # + 004 - it successfully runs local tests against a store with relative paths in the store file: + command: fga model test --tests tests/fixtures/relative-path/relative-path-store.fga.yaml + exit-code: 0 + stderr: # Test Summary #