From ab4d8c65a40333691a5012613b6bd5a6a065ba45 Mon Sep 17 00:00:00 2001 From: Alec Thomas Date: Fri, 10 Nov 2023 09:33:00 +1100 Subject: [PATCH] fix: schema import walk wasn't calling next() (#581) --- backend/schema/schema.go | 2 +- backend/schema/schema_test.go | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/backend/schema/schema.go b/backend/schema/schema.go index 60707db670..2309ede23c 100644 --- a/backend/schema/schema.go +++ b/backend/schema/schema.go @@ -248,7 +248,7 @@ func (m *Module) Imports() []string { default: } - return nil + return next() }) return maps.Keys(imports) } diff --git a/backend/schema/schema_test.go b/backend/schema/schema_test.go index 34a168a7c9..169eecf5bc 100644 --- a/backend/schema/schema_test.go +++ b/backend/schema/schema_test.go @@ -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