Skip to content

Commit

Permalink
Add test making sure file:// works
Browse files Browse the repository at this point in the history
  • Loading branch information
huguesalary committed Oct 3, 2024
1 parent 2b7c953 commit d9d6e57
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions cmd/timoni/bundle_apply_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
}

0 comments on commit d9d6e57

Please sign in to comment.