Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions cmd/model/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package model
import (
"fmt"
"os"
"path"
"path/filepath"
"strings"

Expand Down Expand Up @@ -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)
}
Expand Down
10 changes: 10 additions & 0 deletions tests/fixtures/relative-path/relative-path-store.fga.yaml
Original file line number Diff line number Diff line change
@@ -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
6 changes: 6 additions & 0 deletions tests/import-tests-cases.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
20 changes: 20 additions & 0 deletions tests/model-test-cases.yaml
Original file line number Diff line number Diff line change
@@ -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 #
Loading