add namespace.yaml

This commit is contained in:
Seth Pollack
2018-06-05 18:41:48 -04:00
parent 501e1a406d
commit 815db033cb

View File

@@ -34,13 +34,14 @@ import (
func setupTest(t *testing.T) loader.Loader {
kustomizationContent := []byte(`
namePrefix: foo-
namespace: foo
namespace: ns1
commonLabels:
app: nginx
commonAnnotations:
note: This is a test annotation
resources:
- deployment.yaml
- namespace.yaml
configMapGenerator:
- name: literalConfigMap
literals:
@@ -58,6 +59,11 @@ kind: Deployment
metadata:
name: dply1
`)
namespaceContent := []byte(`apiVersion: v1
kind: Namespace
metadata:
name: ns1
`)
loader := loadertest.NewFakeLoader("/testpath")
err := loader.AddFile("/testpath/"+constants.KustomizationFileName, kustomizationContent)
@@ -68,12 +74,17 @@ metadata:
if err != nil {
t.Fatalf("Failed to setup fake loader.")
}
err = loader.AddFile("/testpath/namespace.yaml", namespaceContent)
if err != nil {
t.Fatalf("Failed to setup fake loader.")
}
return loader
}
var deploy = schema.GroupVersionKind{Group: "apps", Version: "v1", Kind: "Deployment"}
var cmap = schema.GroupVersionKind{Version: "v1", Kind: "ConfigMap"}
var secret = schema.GroupVersionKind{Version: "v1", Kind: "Secret"}
var ns = schema.GroupVersionKind{Version: "v1", Kind: "Namespace"}
func TestResources(t *testing.T) {
expected := resmap.ResMap{
@@ -84,7 +95,7 @@ func TestResources(t *testing.T) {
"kind": "Deployment",
"metadata": map[string]interface{}{
"name": "foo-dply1",
"namespace": "foo",
"namespace": "ns1",
"labels": map[string]interface{}{
"app": "nginx",
},
@@ -118,7 +129,7 @@ func TestResources(t *testing.T) {
"kind": "ConfigMap",
"metadata": map[string]interface{}{
"name": "foo-literalConfigMap-mc92bgcbh5",
"namespace": "foo",
"namespace": "ns1",
"labels": map[string]interface{}{
"app": "nginx",
},
@@ -140,7 +151,7 @@ func TestResources(t *testing.T) {
"kind": "Secret",
"metadata": map[string]interface{}{
"name": "foo-secret-877fcfhgt5",
"namespace": "foo",
"namespace": "ns1",
"labels": map[string]interface{}{
"app": "nginx",
},
@@ -156,6 +167,23 @@ func TestResources(t *testing.T) {
},
},
}),
resource.NewResId(ns, "ns1"): resource.NewBehaviorlessResource(
&unstructured.Unstructured{
Object: map[string]interface{}{
"apiVersion": "v1",
"kind": "Namespace",
"metadata": map[string]interface{}{
"name": "foo-ns1",
"namespace": "ns1",
"labels": map[string]interface{}{
"app": "nginx",
},
"annotations": map[string]interface{}{
"note": "This is a test annotation",
},
},
},
}),
}
l := setupTest(t)
app, err := New(l)
@@ -185,6 +213,16 @@ func TestRawResources(t *testing.T) {
},
},
}),
resource.NewResId(ns, "ns1"): resource.NewBehaviorlessResource(
&unstructured.Unstructured{
Object: map[string]interface{}{
"apiVersion": "v1",
"kind": "Namespace",
"metadata": map[string]interface{}{
"name": "ns1",
},
},
}),
}
l := setupTest(t)
app, err := New(l)