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
10 changes: 10 additions & 0 deletions internal/cmd/validate-test/missing-relation.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
relationships: >-
test:1#viewer@user:1
# notice how schema isn't the first section of the yaml
schema: |-
definition user {}
definition test {
relation viewer: user
permission view = write
}
2 changes: 1 addition & 1 deletion internal/cmd/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ func validateCmdFunc(cmd *cobra.Command, filenames []string) (string, bool, erro
return "", false, err
}
if devErrs != nil {
schemaOffset := 1 /* for the 'schema:' */
schemaOffset := parsed.Schema.SourcePosition.LineNumber
if isOnlySchema {
schemaOffset = 0
}
Expand Down
14 changes: 14 additions & 0 deletions internal/cmd/validate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,20 @@ complete - 0 relationships loaded, 0 assertions run, 0 expected relations valida
"3 | }\n " +
"4 | \n\n\n",
},
`missing_relation_in_yaml_fails`: {
files: []string{
filepath.Join("validate-test", "missing-relation.yaml"),
},
expectNonZeroStatusCode: true,
expectStr: "error: relation/permission `write` not found under definition `test` \n" +
" 6 | definition user {}\n" +
" 7 | definition test {\n" +
" 8 | relation viewer: user\n" +
" 9 > permission view = write\n" +
" > ^~~~~\n" +
" 10 | }\n" +
" 11 | \n\n\n",
},
// TODO: https://github.com/authzed/zed/issues/487
//`url_passes`: {
// files: []string{
Expand Down
Loading