From 118aeb8df53662e3980aa6d3333dadd3cdb6f7dc Mon Sep 17 00:00:00 2001 From: Peefy Date: Mon, 24 Jun 2024 17:28:37 +0800 Subject: [PATCH] test: add relative import in override file API (#335) Signed-off-by: peefy --- pkg/tools/override/kcl.mod | 0 pkg/tools/override/override_test.go | 7 +++++++ pkg/tools/override/testdata/pkg/pkg.k | 1 + pkg/tools/override/testdata/test_with_relative_import.k | 6 ++++++ 4 files changed, 14 insertions(+) create mode 100644 pkg/tools/override/kcl.mod create mode 100644 pkg/tools/override/testdata/pkg/pkg.k create mode 100644 pkg/tools/override/testdata/test_with_relative_import.k diff --git a/pkg/tools/override/kcl.mod b/pkg/tools/override/kcl.mod new file mode 100644 index 00000000..e69de29b diff --git a/pkg/tools/override/override_test.go b/pkg/tools/override/override_test.go index b1eed6a4..a7d21f26 100644 --- a/pkg/tools/override/override_test.go +++ b/pkg/tools/override/override_test.go @@ -16,3 +16,10 @@ func TestOverrideFile(t *testing.T) { t.Fatal(err) } } + +func TestOverrideFileWithRelativeImport(t *testing.T) { + _, err := OverrideFile("./testdata/test_with_relative_import.k", []string{"config.replicas=1"}, []string{}) + if err != nil { + t.Fatal(err) + } +} diff --git a/pkg/tools/override/testdata/pkg/pkg.k b/pkg/tools/override/testdata/pkg/pkg.k new file mode 100644 index 00000000..1337a530 --- /dev/null +++ b/pkg/tools/override/testdata/pkg/pkg.k @@ -0,0 +1 @@ +a = 1 diff --git a/pkg/tools/override/testdata/test_with_relative_import.k b/pkg/tools/override/testdata/test_with_relative_import.k new file mode 100644 index 00000000..921a6205 --- /dev/null +++ b/pkg/tools/override/testdata/test_with_relative_import.k @@ -0,0 +1,6 @@ +import .pkg + +config = { + a = pkg.a + replicas: 1 +}