MCPcopy Create free account
hub / github.com/apache/dubbo-go / TestEncoder_componentsToMap

Function TestEncoder_componentsToMap

protocol/triple/openapi/encoder_test.go:384–398  ·  view source on GitHub ↗

--- componentsToMap tests ---

(t *testing.T)

Source from the content-addressed store, hash-verified

382// --- componentsToMap tests ---
383
384func TestEncoder_componentsToMap(t *testing.T) {
385 e := NewEncoder()
386 c := model.NewComponents()
387 c.AddSchema("User", model.NewSchema().SetType(model.SchemaTypeObject).SetTitle("User"))
388 c.AddSchema("Req", model.NewSchema().SetType(model.SchemaTypeObject).SetTitle("Req"))
389
390 m := e.componentsToMap(c)
391 schemas, ok := m["schemas"].(map[string]any)
392 if !ok {
393 t.Fatal("schemas should be map[string]any")
394 }
395 if len(schemas) != 2 {
396 t.Errorf("expected 2 schemas, got %d", len(schemas))
397 }
398}
399
400func TestEncoder_componentsToMap_Empty(t *testing.T) {
401 e := NewEncoder()

Callers

nothing calls this directly

Calls 9

AddSchemaMethod · 0.95
componentsToMapMethod · 0.95
NewComponentsFunction · 0.92
NewSchemaFunction · 0.92
NewEncoderFunction · 0.85
SetTypeMethod · 0.80
FatalMethod · 0.65
ErrorfMethod · 0.65
SetTitleMethod · 0.45

Tested by

no test coverage detected