@@ -185,7 +185,7 @@ spec:
185185}
186186
187187func TestParseObjectsWithCustomDecoder (t * testing.T ) {
188- // Test that parseObjects respects the custom decoder parameter
188+ // Test that parseObjects can handle CRDs by falling back to unstructured parsing
189189 tektonTaskYAML := `apiVersion: tekton.dev/v1
190190kind: Task
191191metadata:
@@ -200,15 +200,19 @@ spec:
200200 args:
201201 - "Hello World!"`
202202
203- // Test with default decoder (should fail )
203+ // Test with default decoder (should succeed by falling back to unstructured )
204204 objects , err := parseObjects ([]byte (tektonTaskYAML ), nil )
205- assert .Error (t , err , "Expected Tekton Task to fail with default decoder" )
206- assert .Empty (t , objects )
205+ assert .NoError (t , err , "Expected Tekton Task to parse as unstructured with default decoder" )
206+ assert .Len (t , objects , 1 )
207+ assert .Equal (t , "Task" , objects [0 ].GetObjectKind ().GroupVersionKind ().Kind )
208+ assert .Equal (t , "hello-world-task" , objects [0 ].GetName ())
207209
208- // Test with explicit decoder (should also fail since we're using the same decoder )
210+ // Test with explicit decoder (should also succeed )
209211 objects , err = parseObjects ([]byte (tektonTaskYAML ), decoder )
210- assert .Error (t , err , "Expected Tekton Task to fail with current scheme" )
211- assert .Empty (t , objects )
212+ assert .NoError (t , err , "Expected Tekton Task to parse as unstructured with explicit decoder" )
213+ assert .Len (t , objects , 1 )
214+ assert .Equal (t , "Task" , objects [0 ].GetObjectKind ().GroupVersionKind ().Kind )
215+ assert .Equal (t , "hello-world-task" , objects [0 ].GetName ())
212216}
213217
214218func TestParseObjectsEmptyInput (t * testing.T ) {
0 commit comments