Skip to content

Commit

Permalink
fix: schema import walk wasn't calling next() (#581)
Browse files Browse the repository at this point in the history
  • Loading branch information
alecthomas authored Nov 9, 2023
1 parent 01ce2c3 commit ab4d8c6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion backend/schema/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ func (m *Module) Imports() []string {

default:
}
return nil
return next()
})
return maps.Keys(imports)
}
Expand Down
13 changes: 13 additions & 0 deletions backend/schema/schema_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,19 @@ module todo {
assert.Equal(t, strings.TrimSpace(expected), strings.TrimSpace(schema.String()))
}

func TestImports(t *testing.T) {
input := `
module test {
data Data {
ref other.Data
}
}
`
schema, err := ParseModuleString("", input)
assert.NoError(t, err)
assert.Equal(t, []string{"other"}, schema.Imports())
}

func TestVisit(t *testing.T) {
expected := `
Schema
Expand Down

0 comments on commit ab4d8c6

Please sign in to comment.