MCPcopy Create free account
hub / github.com/flant/shell-operator / Test_DeleteOperations

Function Test_DeleteOperations

pkg/kube/object_patch/patch_test.go:802–908  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

800}
801
802func Test_DeleteOperations(t *testing.T) {
803 const (
804 namespace = "default"
805 existingName = "testcm"
806 existingConfigMap = `
807apiVersion: v1
808kind: ConfigMap
809metadata:
810 namespace: default
811 name: testcm
812data:
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(`
849operation: Delete
850kind: ConfigMap
851namespace: %s
852name: %s
853`, namespace, existingName)))
854 if err != nil {
855 return err
856 }
857 return patcher.ExecuteOperations(operations)
858 },
859 shouldDelete,

Callers

nothing calls this directly

Calls 9

ExecuteOperationMethod · 0.95
ExecuteOperationsMethod · 0.95
NewDeleteOperationFunction · 0.85
ParseOperationsFunction · 0.85
NewObjectPatcherFunction · 0.85
existObjectFunction · 0.85
RunMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected