(t *testing.T)
| 1271 | } |
| 1272 | |
| 1273 | func TestDecodeSecrets(t *testing.T) { |
| 1274 | ansi.DisableColors(true) |
| 1275 | |
| 1276 | t.Run("decodeSecrets with valid base64 data", func(t *testing.T) { |
| 1277 | old := &manifest.MappingResult{ |
| 1278 | Name: "default, foo, Secret (v1)", |
| 1279 | Kind: "Secret", |
| 1280 | Content: ` |
| 1281 | apiVersion: v1 |
| 1282 | kind: Secret |
| 1283 | metadata: |
| 1284 | name: foo |
| 1285 | type: Opaque |
| 1286 | data: |
| 1287 | key1: dmFsdWUx |
| 1288 | key2: dmFsdWUy |
| 1289 | `, |
| 1290 | } |
| 1291 | new := &manifest.MappingResult{ |
| 1292 | Name: "default, foo, Secret (v1)", |
| 1293 | Kind: "Secret", |
| 1294 | Content: ` |
| 1295 | apiVersion: v1 |
| 1296 | kind: Secret |
| 1297 | metadata: |
| 1298 | name: foo |
| 1299 | type: Opaque |
| 1300 | data: |
| 1301 | key1: bmV3dmFsdWUx |
| 1302 | key2: dmFsdWUy |
| 1303 | `, |
| 1304 | } |
| 1305 | decodeSecrets(old, new) |
| 1306 | require.Contains(t, old.Content, "key1: value1") |
| 1307 | require.Contains(t, old.Content, "key2: value2") |
| 1308 | require.Contains(t, new.Content, "key1: newvalue1") |
| 1309 | require.Contains(t, new.Content, "key2: value2") |
| 1310 | }) |
| 1311 | |
| 1312 | t.Run("decodeSecrets with stringData", func(t *testing.T) { |
| 1313 | old := &manifest.MappingResult{ |
| 1314 | Name: "default, foo, Secret (v1)", |
| 1315 | Kind: "Secret", |
| 1316 | Content: ` |
| 1317 | apiVersion: v1 |
| 1318 | kind: Secret |
| 1319 | metadata: |
| 1320 | name: foo |
| 1321 | type: Opaque |
| 1322 | stringData: |
| 1323 | key1: value1 |
| 1324 | key2: value2 |
| 1325 | `, |
| 1326 | } |
| 1327 | new := &manifest.MappingResult{ |
| 1328 | Name: "default, foo, Secret (v1)", |
| 1329 | Kind: "Secret", |
| 1330 | Content: ` |
nothing calls this directly
no test coverage detected