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

Function Test_ParseOperations

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

Source from the content-addressed store, hash-verified

26}
27
28func Test_ParseOperations(t *testing.T) {
29 const (
30 shouldNotBeError = false
31 shouldBeError = true
32 )
33
34 tests := []struct {
35 name string
36 testFilePath string
37 expectError bool
38 }{
39 {
40 "valid create",
41 "testdata/serialized_operations/valid_create.yaml",
42 shouldNotBeError,
43 },
44 {
45 "invalid create",
46 "testdata/serialized_operations/invalid_create.yaml",
47 shouldBeError,
48 },
49 {
50 "valid delete",
51 "testdata/serialized_operations/valid_delete.yaml",
52 shouldNotBeError,
53 },
54 {
55 "invalid delete",
56 "testdata/serialized_operations/invalid_delete.yaml",
57 shouldBeError,
58 },
59 {
60 "valid patch",
61 "testdata/serialized_operations/valid_patch.yaml",
62 shouldNotBeError,
63 },
64 {
65 "invalid patch",
66 "testdata/serialized_operations/invalid_patch.yaml",
67 shouldBeError,
68 },
69 }
70 for _, tt := range tests {
71 t.Run(tt.name, func(t *testing.T) {
72 testSpecs := mustReadFile(t, tt.testFilePath)
73
74 _, err := ParseOperations(testSpecs)
75 if tt.expectError {
76 require.Error(t, err)
77 } else {
78 require.NoError(t, err)
79 }
80 })
81 }
82}
83
84func Test_PatchOperations(t *testing.T) {
85 const (

Callers

nothing calls this directly

Calls 4

mustReadFileFunction · 0.85
ParseOperationsFunction · 0.85
RunMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected