| 681 | } |
| 682 | |
| 683 | func TestStructuredOutputSuppressedKind(t *testing.T) { |
| 684 | ansi.DisableColors(true) |
| 685 | opts := &Options{ |
| 686 | OutputFormat: "structured", |
| 687 | SuppressedKinds: []string{"Secret"}, |
| 688 | } |
| 689 | oldManifest := ` |
| 690 | apiVersion: v1 |
| 691 | kind: Secret |
| 692 | metadata: |
| 693 | name: creds |
| 694 | data: |
| 695 | password: c29tZQ== |
| 696 | ` |
| 697 | newManifest := ` |
| 698 | apiVersion: v1 |
| 699 | kind: Secret |
| 700 | metadata: |
| 701 | name: creds |
| 702 | data: |
| 703 | password: Zm9v |
| 704 | ` |
| 705 | oldIndex := manifest.Parse([]byte(oldManifest), "default", true) |
| 706 | newIndex := manifest.Parse([]byte(newManifest), "default", true) |
| 707 | |
| 708 | var buf bytes.Buffer |
| 709 | changed := Manifests(oldIndex, newIndex, opts, &buf) |
| 710 | require.True(t, changed) |
| 711 | |
| 712 | var entries []StructuredEntry |
| 713 | require.NoError(t, json.Unmarshal(buf.Bytes(), &entries)) |
| 714 | require.Len(t, entries, 1) |
| 715 | require.True(t, entries[0].ChangesSuppressed) |
| 716 | require.Empty(t, entries[0].Changes) |
| 717 | } |
| 718 | |
| 719 | func findChange(changes []FieldChange, path, field string) (FieldChange, bool) { |
| 720 | for _, change := range changes { |