|
|
@ -17,6 +17,7 @@ limitations under the License.
|
|
|
|
package tiller
|
|
|
|
package tiller
|
|
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
import (
|
|
|
|
|
|
|
|
"bytes"
|
|
|
|
"testing"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
|
|
|
|
util "k8s.io/helm/pkg/releaseutil"
|
|
|
|
util "k8s.io/helm/pkg/releaseutil"
|
|
|
@ -27,48 +28,77 @@ func TestKindSorter(t *testing.T) {
|
|
|
|
{
|
|
|
|
{
|
|
|
|
name: "m",
|
|
|
|
name: "m",
|
|
|
|
content: "",
|
|
|
|
content: "",
|
|
|
|
head: &util.SimpleHead{Kind: "Deployment"},
|
|
|
|
head: &util.SimpleHead{Kind: "ClusterRole"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
name: "l",
|
|
|
|
name: " ",
|
|
|
|
content: "",
|
|
|
|
content: "",
|
|
|
|
head: &util.SimpleHead{Kind: "Service"},
|
|
|
|
head: &util.SimpleHead{Kind: "ClusterRoleBinding"},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
name: "e",
|
|
|
|
|
|
|
|
content: "",
|
|
|
|
|
|
|
|
head: &util.SimpleHead{Kind: "ConfigMap"},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
name: "k",
|
|
|
|
|
|
|
|
content: "",
|
|
|
|
|
|
|
|
head: &util.SimpleHead{Kind: "Deployment"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
name: "!",
|
|
|
|
name: "!",
|
|
|
|
content: "",
|
|
|
|
content: "",
|
|
|
|
head: &util.SimpleHead{Kind: "HonkyTonkSet"},
|
|
|
|
head: &util.SimpleHead{Kind: "HonkyTonkSet"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
name: "s",
|
|
|
|
|
|
|
|
content: "",
|
|
|
|
|
|
|
|
head: &util.SimpleHead{Kind: "Job"},
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
name: "h",
|
|
|
|
name: "h",
|
|
|
|
content: "",
|
|
|
|
content: "",
|
|
|
|
head: &util.SimpleHead{Kind: "Namespace"},
|
|
|
|
head: &util.SimpleHead{Kind: "Namespace"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
name: "e",
|
|
|
|
name: "w",
|
|
|
|
content: "",
|
|
|
|
content: "",
|
|
|
|
head: &util.SimpleHead{Kind: "ConfigMap"},
|
|
|
|
head: &util.SimpleHead{Kind: "Role"},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
name: "o",
|
|
|
|
|
|
|
|
content: "",
|
|
|
|
|
|
|
|
head: &util.SimpleHead{Kind: "RoleBinding"},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
name: "r",
|
|
|
|
|
|
|
|
content: "",
|
|
|
|
|
|
|
|
head: &util.SimpleHead{Kind: "Service"},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
name: "l",
|
|
|
|
|
|
|
|
content: "",
|
|
|
|
|
|
|
|
head: &util.SimpleHead{Kind: "ServiceAccount"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
res := sortByKind(manifests, InstallOrder)
|
|
|
|
for _, test := range []struct {
|
|
|
|
got := ""
|
|
|
|
description string
|
|
|
|
expect := "helm!"
|
|
|
|
order SortOrder
|
|
|
|
for _, r := range res {
|
|
|
|
expected string
|
|
|
|
got += r.name
|
|
|
|
}{
|
|
|
|
}
|
|
|
|
{"install", InstallOrder, "helm works!"},
|
|
|
|
if got != expect {
|
|
|
|
{"uninstall", UninstallOrder, "rkeow mlsh!"},
|
|
|
|
t.Errorf("Expected %q, got %q", expect, got)
|
|
|
|
} {
|
|
|
|
}
|
|
|
|
var buf bytes.Buffer
|
|
|
|
|
|
|
|
t.Run(test.description, func(t *testing.T) {
|
|
|
|
expect = "lmeh!"
|
|
|
|
defer buf.Reset()
|
|
|
|
got = ""
|
|
|
|
for _, r := range sortByKind(manifests, test.order) {
|
|
|
|
res = sortByKind(manifests, UninstallOrder)
|
|
|
|
buf.WriteString(r.name)
|
|
|
|
for _, r := range res {
|
|
|
|
}
|
|
|
|
got += r.name
|
|
|
|
if got := buf.String(); got != test.expected {
|
|
|
|
|
|
|
|
t.Errorf("Expected %q, got %q", test.expected, got)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if got != expect {
|
|
|
|
|
|
|
|
t.Errorf("Expected %q, got %q", expect, got)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|