This repository has been archived by the owner on Feb 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
helmdeploy_test.go
109 lines (96 loc) · 2.12 KB
/
helmdeploy_test.go
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
package main
import (
"testing"
"k8s.io/helm/pkg/chartutil"
"k8s.io/helm/pkg/helm"
hapi_release "k8s.io/helm/pkg/proto/hapi/release"
)
func TestNewDeployerFromManifest(t *testing.T) {
}
type FakeClient struct {
helm.FakeClient
}
func TestIsIstalled(t *testing.T) {
deploy := &Deploy{
ReleaseName: "chaoskube",
Namespace: "default",
TillerClient: &helm.FakeClient{
Rels: []*hapi_release.Release{
&hapi_release.Release{Name: "chaoskube"},
},
},
}
installed := deploy.IsInstalled()
if installed != true {
t.Errorf("Unexpected IsInstalled() : %v", installed)
}
deploy.TillerClient = &helm.FakeClient{
Rels: nil,
}
installed = deploy.IsInstalled()
if installed != false {
t.Errorf("Unexpected IsInstalled() : %v", installed)
}
}
func TestDeploy(t *testing.T) {
deploy := &Deploy{
ReleaseName: "chaoskube",
Namespace: "default",
TillerClient: &FakeClient{
FakeClient: helm.FakeClient{
Rels: []*hapi_release.Release{
&hapi_release.Release{Name: "chaoskube"},
},
},
},
}
release, err := deploy.Deploy(true)
if err != nil {
t.Fatal(err)
}
if release.Name != "chaoskube" {
t.Errorf("Unexpected release : %v", release)
}
}
func TestContent(t *testing.T) {
deploy := &Deploy{
ReleaseName: "chaoskube",
Namespace: "default",
TillerClient: &FakeClient{
FakeClient: helm.FakeClient{
Rels: []*hapi_release.Release{
&hapi_release.Release{Name: "chaoskube"},
},
},
},
}
release, err := deploy.Content()
if err != nil {
t.Fatal(err)
}
if release.Name != "chaoskube" {
t.Errorf("Unexpected release : %v", release)
}
}
func TestRender(t *testing.T) {
manifest, err := NewManifestFromFile("./examples/kubernetes-dashboard-release.yaml")
if err != nil {
t.Fatal(err)
}
chart, err := chartutil.Load(manifest.Chart)
if err != nil {
t.Fatal(err)
}
deploy := &Deploy{
ReleaseName: manifest.Name,
Namespace: manifest.Namespace,
Chart: chart,
}
res, err := deploy.Render()
if err != nil {
t.Fatal(err)
}
if _, ok := res["kubernetes-dashboard/templates/deployment.yaml"]; !ok {
t.Errorf("Unexpected templating result : %v", res)
}
}