| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
package merge3_test |
| 5 |
|
| 6 |
var mapTestCases = []testCase{ |
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
{ |
| 11 |
description: `Add the annotations map field`, |
| 12 |
origin: ` |
| 13 |
kind: Deployment`, |
| 14 |
update: ` |
| 15 |
kind: Deployment |
| 16 |
metadata: |
| 17 |
annotations: |
| 18 |
d: e # add these annotations |
| 19 |
`, |
| 20 |
local: ` |
| 21 |
kind: Deployment`, |
| 22 |
expected: ` |
| 23 |
kind: Deployment |
| 24 |
metadata: |
| 25 |
annotations: |
| 26 |
d: e # add these annotations`}, |
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
{ |
| 32 |
description: `Add an annotation to the field`, |
| 33 |
origin: ` |
| 34 |
kind: Deployment |
| 35 |
metadata: |
| 36 |
annotations: |
| 37 |
a: b`, |
| 38 |
update: ` |
| 39 |
kind: Deployment |
| 40 |
metadata: |
| 41 |
annotations: |
| 42 |
a: b |
| 43 |
d: e # add these annotations`, |
| 44 |
local: ` |
| 45 |
kind: Deployment |
| 46 |
metadata: |
| 47 |
annotations: |
| 48 |
g: h # keep these annotations`, |
| 49 |
expected: ` |
| 50 |
kind: Deployment |
| 51 |
metadata: |
| 52 |
annotations: |
| 53 |
g: h # keep these annotations |
| 54 |
d: e # add these annotations`}, |
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
{ |
| 60 |
description: `Add an annotation to the field, field missing from dest`, |
| 61 |
origin: ` |
| 62 |
kind: Deployment |
| 63 |
metadata: |
| 64 |
annotations: |
| 65 |
a: b # ignored because unchanged`, |
| 66 |
update: ` |
| 67 |
kind: Deployment |
| 68 |
metadata: |
| 69 |
annotations: |
| 70 |
a: b # ignored because unchanged |
| 71 |
d: e`, |
| 72 |
local: ` |
| 73 |
kind: Deployment`, |
| 74 |
expected: ` |
| 75 |
kind: Deployment |
| 76 |
metadata: |
| 77 |
annotations: |
| 78 |
d: e`}, |
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
{ |
| 84 |
description: `Update an annotation on the field, field messing rom the dest`, |
| 85 |
origin: ` |
| 86 |
kind: Deployment |
| 87 |
metadata: |
| 88 |
annotations: |
| 89 |
a: b |
| 90 |
d: c`, |
| 91 |
update: ` |
| 92 |
kind: Deployment |
| 93 |
metadata: |
| 94 |
annotations: |
| 95 |
a: b |
| 96 |
d: e # set these annotations`, |
| 97 |
local: ` |
| 98 |
kind: Deployment |
| 99 |
metadata: |
| 100 |
annotations: |
| 101 |
g: h # keep these annotations`, |
| 102 |
expected: ` |
| 103 |
kind: Deployment |
| 104 |
metadata: |
| 105 |
annotations: |
| 106 |
g: h # keep these annotations |
| 107 |
d: e # set these annotations`}, |
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
{ |
| 113 |
description: `Add an annotation to the field, field missing from dest`, |
| 114 |
origin: ` |
| 115 |
kind: Deployment |
| 116 |
metadata: |
| 117 |
annotations: |
| 118 |
a: b # ignored because unchanged`, |
| 119 |
update: ` |
| 120 |
kind: Deployment |
| 121 |
metadata: |
| 122 |
annotations: |
| 123 |
a: b # ignored because unchanged |
| 124 |
d: e`, |
| 125 |
local: ` |
| 126 |
kind: Deployment`, |
| 127 |
expected: ` |
| 128 |
kind: Deployment |
| 129 |
metadata: |
| 130 |
annotations: |
| 131 |
d: e`}, |
| 132 |
|
| 133 |
|
| 134 |
|
| 135 |
|
| 136 |
{ |
| 137 |
description: `Remove an annotation`, |
| 138 |
origin: ` |
| 139 |
apiVersion: apps/v1 |
| 140 |
kind: Deployment |
| 141 |
metadata: |
| 142 |
annotations: |
| 143 |
a: b`, |
| 144 |
update: ` |
| 145 |
apiVersion: apps/v1 |
| 146 |
kind: Deployment |
| 147 |
metadata: |
| 148 |
annotations: {}`, |
| 149 |
local: ` |
| 150 |
apiVersion: apps/v1 |
| 151 |
kind: Deployment |
| 152 |
metadata: |
| 153 |
annotations: |
| 154 |
c: d |
| 155 |
a: b`, |
| 156 |
expected: ` |
| 157 |
apiVersion: apps/v1 |
| 158 |
kind: Deployment |
| 159 |
metadata: |
| 160 |
annotations: |
| 161 |
c: d`}, |
| 162 |
|
| 163 |
|
| 164 |
|
| 165 |
|
| 166 |
|
| 167 |
{ |
| 168 |
description: `Specify a field as empty that isn't present in the source`, |
| 169 |
origin: ` |
| 170 |
apiVersion: apps/v1 |
| 171 |
kind: Deployment |
| 172 |
metadata: |
| 173 |
name: foo`, |
| 174 |
update: ` |
| 175 |
apiVersion: apps/v1 |
| 176 |
kind: Deployment |
| 177 |
metadata: |
| 178 |
name: foo |
| 179 |
annotations: null`, |
| 180 |
local: ` |
| 181 |
apiVersion: apps/v1 |
| 182 |
kind: Deployment |
| 183 |
metadata: |
| 184 |
name: foo |
| 185 |
annotations: |
| 186 |
a: b`, |
| 187 |
expected: ` |
| 188 |
apiVersion: apps/v1 |
| 189 |
kind: Deployment |
| 190 |
metadata: |
| 191 |
name: foo`}, |
| 192 |
|
| 193 |
|
| 194 |
|
| 195 |
|
| 196 |
{ |
| 197 |
description: `Remove an annotation`, |
| 198 |
origin: ` |
| 199 |
apiVersion: apps/v1 |
| 200 |
kind: Deployment |
| 201 |
metadata: |
| 202 |
annotations: |
| 203 |
a: b`, |
| 204 |
update: ` |
| 205 |
apiVersion: apps/v1 |
| 206 |
kind: Deployment`, |
| 207 |
local: ` |
| 208 |
apiVersion: apps/v1 |
| 209 |
kind: Deployment |
| 210 |
metadata: |
| 211 |
annotations: |
| 212 |
c: d |
| 213 |
a: b`, |
| 214 |
expected: ` |
| 215 |
apiVersion: apps/v1 |
| 216 |
kind: Deployment |
| 217 |
metadata: |
| 218 |
annotations: |
| 219 |
c: d`}, |
| 220 |
|
| 221 |
|
| 222 |
|
| 223 |
|
| 224 |
{ |
| 225 |
description: `Remove annotations field`, |
| 226 |
origin: ` |
| 227 |
apiVersion: apps/v1 |
| 228 |
kind: Deployment |
| 229 |
metadata: |
| 230 |
annotations: |
| 231 |
a: b`, |
| 232 |
update: ` |
| 233 |
apiVersion: apps/v1 |
| 234 |
kind: Deployment`, |
| 235 |
local: ` |
| 236 |
apiVersion: apps/v1 |
| 237 |
kind: Deployment |
| 238 |
metadata: |
| 239 |
name: foo`, |
| 240 |
expected: ` |
| 241 |
apiVersion: apps/v1 |
| 242 |
kind: Deployment |
| 243 |
metadata: |
| 244 |
name: foo |
| 245 |
`}, |
| 246 |
|
| 247 |
|
| 248 |
|
| 249 |
|
| 250 |
{ |
| 251 |
description: `Remove annotations field, but keep in dest`, |
| 252 |
origin: ` |
| 253 |
apiVersion: apps/v1 |
| 254 |
kind: Deployment |
| 255 |
metadata: |
| 256 |
annotations: |
| 257 |
a: b`, |
| 258 |
update: ` |
| 259 |
apiVersion: apps/v1 |
| 260 |
kind: Deployment`, |
| 261 |
local: ` |
| 262 |
apiVersion: apps/v1 |
| 263 |
kind: Deployment |
| 264 |
metadata: |
| 265 |
name: foo |
| 266 |
annotations: |
| 267 |
foo: bar # keep this annotation even though the parent field was removed`, |
| 268 |
expected: ` |
| 269 |
apiVersion: apps/v1 |
| 270 |
kind: Deployment |
| 271 |
metadata: |
| 272 |
name: foo |
| 273 |
annotations: |
| 274 |
foo: bar # keep this annotation even though the parent field was removed`}, |
| 275 |
|
| 276 |
|
| 277 |
|
| 278 |
|
| 279 |
{ |
| 280 |
description: `Remove annotations, but they are already empty`, |
| 281 |
origin: ` |
| 282 |
apiVersion: apps/v1 |
| 283 |
kind: Deployment |
| 284 |
metadata: |
| 285 |
name: foo |
| 286 |
annotations: |
| 287 |
a: b |
| 288 |
`, |
| 289 |
update: ` |
| 290 |
apiVersion: apps/v1 |
| 291 |
kind: Deployment |
| 292 |
metadata: |
| 293 |
name: foo |
| 294 |
`, |
| 295 |
local: ` |
| 296 |
apiVersion: apps/v1 |
| 297 |
kind: Deployment |
| 298 |
metadata: |
| 299 |
name: foo |
| 300 |
annotations: {} |
| 301 |
`, |
| 302 |
expected: ` |
| 303 |
apiVersion: apps/v1 |
| 304 |
kind: Deployment |
| 305 |
metadata: |
| 306 |
name: foo |
| 307 |
annotations: {} |
| 308 |
`}, |
| 309 |
|
| 310 |
|
| 311 |
|
| 312 |
|
| 313 |
{ |
| 314 |
description: `Verify key style behavior`, |
| 315 |
origin: ` |
| 316 |
apiVersion: v1 |
| 317 |
kind: ConfigMap |
| 318 |
metadata: |
| 319 |
name: foo |
| 320 |
data: |
| 321 |
unchanged: origin |
| 322 |
unchanged-varying-key-style: origin |
| 323 |
deleted-in-update: origin |
| 324 |
deleted-in-local: origin |
| 325 |
`, |
| 326 |
update: ` |
| 327 |
apiVersion: v1 |
| 328 |
kind: ConfigMap |
| 329 |
metadata: |
| 330 |
name: foo |
| 331 |
data: |
| 332 |
unchanged: origin |
| 333 |
'unchanged-varying-key-style': origin |
| 334 |
deleted-in-local: origin |
| 335 |
'added-in-update': 'update' |
| 336 |
'added-in-update-and-local-same-value': 'update-and-local' |
| 337 |
'added-in-update-and-local-diff-value': 'update' |
| 338 |
`, |
| 339 |
local: ` |
| 340 |
apiVersion: v1 |
| 341 |
kind: ConfigMap |
| 342 |
metadata: |
| 343 |
name: foo |
| 344 |
data: |
| 345 |
unchanged: origin |
| 346 |
"unchanged-varying-key-style": origin |
| 347 |
deleted-in-update: origin |
| 348 |
"added-in-local": "local" |
| 349 |
"added-in-update-and-local-same-value": "update-and-local" |
| 350 |
"added-in-update-and-local-diff-value": "local" |
| 351 |
`, |
| 352 |
expected: ` |
| 353 |
apiVersion: v1 |
| 354 |
kind: ConfigMap |
| 355 |
metadata: |
| 356 |
name: foo |
| 357 |
data: |
| 358 |
unchanged: origin |
| 359 |
"unchanged-varying-key-style": origin |
| 360 |
"added-in-local": "local" |
| 361 |
"added-in-update-and-local-same-value": "update-and-local" |
| 362 |
"added-in-update-and-local-diff-value": "update" |
| 363 |
'added-in-update': 'update' |
| 364 |
`, |
| 365 |
}, |
| 366 |
} |