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) + }) +}