MCPcopy
hub / github.com/fluid-cloudnative/fluid / TestFromRawToObject

Function TestFromRawToObject

pkg/utils/raw_test.go:76–113  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

74`
75
76func TestFromRawToObject(t *testing.T) {
77 type testcase struct {
78 name string
79 content string
80 expect string
81 }
82
83 testcases := []testcase{
84 {
85 name: "pod",
86 content: podYaml,
87 expect: "v1.Pod",
88 }, {
89 name: "tfjob",
90 content: tfjobYaml,
91 expect: "unstructured.Unstructured",
92 },
93 }
94
95 for _, testcase := range testcases {
96 obj, err := FromRawToObject([]byte(testcase.content))
97 if err != nil {
98 t.Errorf("failed due to error %v", err)
99 }
100
101 ref := reflect.TypeOf(obj)
102 if ref.Kind().String() == testcase.expect {
103 t.Errorf("the testcase %s failed: the expected result is %s, not %s",
104 testcase.name,
105 testcase.expect,
106 ref.Kind().String())
107 }
108 // gvk := obj.GetObjectKind().GroupVersionKind()
109 // if gvk.Kind != testcase.expect {
110 // t.Errorf("the expected result is %s, not %s", testcase.expect, gvk.Kind)
111 // }
112 }
113}

Callers

nothing calls this directly

Calls 2

FromRawToObjectFunction · 0.85
StringMethod · 0.45

Tested by

no test coverage detected