(t *testing.T)
| 800 | } |
| 801 | |
| 802 | func Test_DeleteOperations(t *testing.T) { |
| 803 | const ( |
| 804 | namespace = "default" |
| 805 | existingName = "testcm" |
| 806 | existingConfigMap = ` |
| 807 | apiVersion: v1 |
| 808 | kind: ConfigMap |
| 809 | metadata: |
| 810 | namespace: default |
| 811 | name: testcm |
| 812 | data: |
| 813 | foo: "bar" |
| 814 | ` |
| 815 | missingName = "missing-object" |
| 816 | |
| 817 | shouldNotDelete = false |
| 818 | shouldDelete = true |
| 819 | shouldNotBeError = false |
| 820 | shouldBeError = true |
| 821 | ) |
| 822 | |
| 823 | tests := []struct { |
| 824 | name string |
| 825 | fn func(patcher *ObjectPatcher) error |
| 826 | expectDeleted bool |
| 827 | expectError bool |
| 828 | }{ |
| 829 | { |
| 830 | "delete existing object", |
| 831 | func(patcher *ObjectPatcher) error { |
| 832 | return patcher.ExecuteOperation(NewDeleteOperation("", "ConfigMap", namespace, existingName)) |
| 833 | }, |
| 834 | shouldDelete, |
| 835 | shouldNotBeError, |
| 836 | }, |
| 837 | { |
| 838 | "delete missing object", |
| 839 | func(patcher *ObjectPatcher) error { |
| 840 | return patcher.ExecuteOperation(NewDeleteOperation("", "ConfigMap", namespace, missingName)) |
| 841 | }, |
| 842 | shouldNotDelete, |
| 843 | shouldNotBeError, |
| 844 | }, |
| 845 | { |
| 846 | "delete existing object via YAML spec", |
| 847 | func(patcher *ObjectPatcher) error { |
| 848 | operations, err := ParseOperations([]byte(fmt.Sprintf(` |
| 849 | operation: Delete |
| 850 | kind: ConfigMap |
| 851 | namespace: %s |
| 852 | name: %s |
| 853 | `, namespace, existingName))) |
| 854 | if err != nil { |
| 855 | return err |
| 856 | } |
| 857 | return patcher.ExecuteOperations(operations) |
| 858 | }, |
| 859 | shouldDelete, |
nothing calls this directly
no test coverage detected