Added real test for adding anchor
@@ -477,31 +477,62 @@ func TestApplyOverlay_AddingAnchor(t *testing.T) {
func TestApplyOverlay_AddingAnchorInsideListElement(t *testing.T) {
overlayRaw := []byte(`
{
- "list" : [
+ "spec": {
+ "template": {
+ "spec": {
+ "containers": [
{
- "(entity)": "*able",
- "+(event)": "process"
+ "(image)": "*:latest",
+ "+(imagePullPolicy)": "IfNotPresent"
}
]
+ }
+ }
+ }
}`)
resourceRaw := []byte(`
{
- "list" : [
+ "apiVersion":"apps/v1",
+ "kind":"Deployment",
+ "metadata":{
+ "name":"nginx-deployment",
+ "labels":{
+ "app":"nginx"
+ }
+ },
+ "spec":{
+ "replicas":1,
+ "selector":{
+ "matchLabels":{
+ "app":"nginx"
+ }
+ },
+ "template":{
+ "metadata":{
+ "labels":{
+ "app":"nginx"
+ }
+ },
+ "spec":{
+ "containers":[
{
- "entity": "movable"
+ "image":"nginx:latest"
},
{
- "entity": "collisionable",
- "event": "skip"
+ "image":"ghost:latest",
+ "imagePullPolicy":"Always"
},
{
- "entity": "any",
- "event": "delete"
+ "image":"debian:10"
},
{
- "entity": "none"
+ "image":"ubuntu:18.04",
+ "imagePullPolicy":"Always"
}
]
+ }
+ }
+ }
}`)
var resource, overlay interface{}
@@ -517,24 +548,48 @@ func TestApplyOverlay_AddingAnchorInsideListElement(t *testing.T) {
assert.NilError(t, err)
expectedResult := []byte(`
{
- "list":[
+ "apiVersion":"apps/v1",
+ "kind":"Deployment",
+ "metadata":{
+ "name":"nginx-deployment",
+ "labels":{
+ "app":"nginx"
+ }
+ },
+ "spec":{
+ "replicas":1,
+ "selector":{
+ "matchLabels":{
+ "app":"nginx"
+ }
+ },
+ "template":{
+ "metadata":{
+ "labels":{
+ "app":"nginx"
+ }
+ },
+ "spec":{
+ "containers":[
{
- "entity":"movable",
- "event":"process"
+ "image":"nginx:latest",
+ "imagePullPolicy":"IfNotPresent"
},
{
- "entity":"collisionable",
- "event":"skip"
+ "image":"ghost:latest",
+ "imagePullPolicy":"Always"
},
{
- "entity":"any",
- "event":"delete"
+ "image":"debian:10"
},
{
- "entity":"none"
+ "image":"ubuntu:18.04",
+ "imagePullPolicy":"Always"
}
]
+ }
+ }
+ }
}`)
-
compareJsonAsMap(t, expectedResult, doc)
}
