forked from devstream-io/devstream
-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathinstaller_test.go
More file actions
89 lines (77 loc) · 1.95 KB
/
Copy pathinstaller_test.go
File metadata and controls
89 lines (77 loc) · 1.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
package kubectl
import (
"fmt"
"io"
"net/http"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/onsi/gomega/ghttp"
"github.com/devstream-io/devstream/internal/pkg/configmanager"
utilKubectl "github.com/devstream-io/devstream/pkg/util/kubectl"
)
var _ = Describe("renderKubectlContent", func() {
var (
content string
options configmanager.RawOptions
)
BeforeEach(func() {
content = `metadata:
name: "[[ .app.name ]]"
namespace: "[[ .app.namespace ]]"
finalizers:
- resources-finalizer.argocd.argoproj.io
`
options = map[string]interface{}{
"app": map[string]interface{}{
"name": "app-name",
"namespace": "app-namespace",
},
}
})
It("should render kubectl content", func() {
contentExpected := `metadata:
name: "app-name"
namespace: "app-namespace"
finalizers:
- resources-finalizer.argocd.argoproj.io
`
reader, err := renderKubectlContent(content, options)
Expect(err).To(Succeed())
bytes, err := io.ReadAll(reader)
Expect(err).To(Succeed())
Expect(string(bytes)).To(Equal(contentExpected))
})
})
var _ = Describe("ProcessByContent", Ordered, func() {
var options configmanager.RawOptions
var s *ghttp.Server
BeforeAll(func() {
s = ghttp.NewServer()
s.RouteToHandler("GET", "/", func(w http.ResponseWriter, r *http.Request) {
fmt.Fprint(w, "ok")
})
})
AfterAll(func() {
s.Close()
})
It("should return error if content is empty", func() {
op := ProcessByContent(utilKubectl.Apply, "")
err := op(options)
Expect(err).To(HaveOccurred())
})
It("action is kubectl apply", func() {
op := ProcessByURL(utilKubectl.Apply, s.URL())
err := op(options)
Expect(err).To(HaveOccurred())
})
It("action is kubectl create", func() {
op := ProcessByURL(utilKubectl.Create, s.URL())
err := op(options)
Expect(err).To(HaveOccurred())
})
It("action is not support", func() {
op := ProcessByURL("", s.URL())
err := op(options)
Expect(err).To(HaveOccurred())
})
})