(t *testing.T)
| 2459 | } |
| 2460 | |
| 2461 | func TestBuildPolicyDiffDisplay(t *testing.T) { |
| 2462 | tests := []struct { |
| 2463 | name string |
| 2464 | data AllSectionsData |
| 2465 | expected *PolicyDiffDisplay |
| 2466 | }{ |
| 2467 | { |
| 2468 | name: "no policy diff", |
| 2469 | data: AllSectionsData{ |
| 2470 | HasPolicyDiff: false, |
| 2471 | }, |
| 2472 | expected: nil, |
| 2473 | }, |
| 2474 | { |
| 2475 | name: "policy diff with all changes", |
| 2476 | data: AllSectionsData{ |
| 2477 | HasPolicyDiff: true, |
| 2478 | AffectedImages: []string{"abc12345", "def67890"}, |
| 2479 | PolicyDiffCounts: map[string]PolicyDiffCounts{ |
| 2480 | "abc12345": {Added: 2, Removed: 1, Changed: 0}, |
| 2481 | "def67890": {Added: 1, Removed: 0, Changed: 2}, |
| 2482 | }, |
| 2483 | }, |
| 2484 | expected: &PolicyDiffDisplay{ |
| 2485 | AffectedImages: "abc12345, def67890", |
| 2486 | Added: "[include] 3", |
| 2487 | Removed: "1", |
| 2488 | Changed: "2", |
| 2489 | }, |
| 2490 | }, |
| 2491 | { |
| 2492 | name: "policy diff with only added", |
| 2493 | data: AllSectionsData{ |
| 2494 | HasPolicyDiff: true, |
| 2495 | AffectedImages: []string{"abc12345"}, |
| 2496 | PolicyDiffCounts: map[string]PolicyDiffCounts{ |
| 2497 | "abc12345": {Added: 5, Removed: 0, Changed: 0}, |
| 2498 | }, |
| 2499 | }, |
| 2500 | expected: &PolicyDiffDisplay{ |
| 2501 | AffectedImages: "abc12345", |
| 2502 | Added: "[include] 5", |
| 2503 | Removed: "none", |
| 2504 | Changed: "none", |
| 2505 | }, |
| 2506 | }, |
| 2507 | { |
| 2508 | name: "policy diff with only removed", |
| 2509 | data: AllSectionsData{ |
| 2510 | HasPolicyDiff: true, |
| 2511 | AffectedImages: []string{"abc12345"}, |
| 2512 | PolicyDiffCounts: map[string]PolicyDiffCounts{ |
| 2513 | "abc12345": {Added: 0, Removed: 3, Changed: 0}, |
| 2514 | }, |
| 2515 | }, |
| 2516 | expected: &PolicyDiffDisplay{ |
| 2517 | AffectedImages: "abc12345", |
| 2518 | Added: "none", |
nothing calls this directly
no test coverage detected