From d9d6e57d27b35b461db1a0d12d6c9e1ec6b1934a Mon Sep 17 00:00:00 2001 From: Hugues Alary Date: Wed, 2 Oct 2024 19:17:47 -0700 Subject: [PATCH] Add test making sure file:// works --- cmd/timoni/bundle_apply_test.go | 58 +++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/cmd/timoni/bundle_apply_test.go b/cmd/timoni/bundle_apply_test.go index 31b480d9..b50f8016 100644 --- a/cmd/timoni/bundle_apply_test.go +++ b/cmd/timoni/bundle_apply_test.go @@ -592,3 +592,61 @@ runtime: { g.Expect(err.Error()).To(ContainSubstring("no cluster found")) }) } + +func Test_BundleApply_Runtime_LocalModule(t *testing.T) { + g := NewWithT(t) + + bundleName := "my-bundle" + modPath := "testdata/module" + namespace := rnd("my-ns", 5) + modVer := "1.0.0" + + bundleData := fmt.Sprintf(` +bundle: { + apiVersion: "v1alpha1" + name: "%[1]s" + instances: { + app: { + module: { + url: "file://%[2]s" + version: "%[3]s" + } + namespace: "%[4]s" + } + } +} +`, bundleName, modPath, modVer, namespace) + + runtimeData := ` +runtime: { + apiVersion: "v1alpha1" + name: "test" + clusters: { + "test": { + group: "testing" + kubeContext: "envtest" + } + "staging": { + group: "staging" + kubeContext: "envtest" + } + } +} +` + + runtimePath := filepath.Join(t.TempDir(), "runtime.cue") + err := os.WriteFile(runtimePath, []byte(runtimeData), 0644) + g.Expect(err).ToNot(HaveOccurred()) + + t.Run("creates instances from bundle and runtime", func(t *testing.T) { + g := NewWithT(t) + + cmd := fmt.Sprintf("bundle apply -p main --wait -f- -r=%s", + runtimePath, + ) + + output, err := executeCommandWithIn(cmd, strings.NewReader(bundleData)) + g.Expect(err).ToNot(HaveOccurred()) + t.Log("\n", output) + }) +}