MCPcopy Create free account
hub / github.com/goadesign/goa / TestTypesOnlyDifferByEnum

Function TestTypesOnlyDifferByEnum

http/codegen/openapi/v3/types_test.go:458–486  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

456}
457
458func TestTypesOnlyDifferByEnum(t *testing.T) {
459 root := codegen.RunDSL(t, dsls.StringEnumBodyDSL())
460
461 bodies, types := buildBodyTypes(root.API, root.Types, root.ResultTypes)
462
463 svc1, ok := bodies["svc_enum_1"]
464 if !ok {
465 t.Errorf("bodies does not contain details for service %q", "svc_enum_1")
466 return
467 }
468 svc2, ok := bodies["svc_enum_2"]
469 if !ok {
470 t.Errorf("bodies does not contain details for service %q", "svc_enum_2")
471 return
472 }
473
474 svc1MethodRB := svc1["method_enum"].RequestBody.Ref
475 svc2MethodRB := svc2["method_enum"].RequestBody.Ref
476
477 if svc1MethodRB == svc2MethodRB {
478 t.Errorf("expected different refs, got %q", svc1MethodRB)
479
480 name := nameFromRef(svc1MethodRB)
481 derefed := types[name]
482 jsoned, _ := json.Marshal(derefed)
483 t.Errorf("shared referenced type (%s) was: %v", name, string(jsoned))
484 return
485 }
486}
487
488func TestHashAttribute(t *testing.T) {
489 type (

Callers

nothing calls this directly

Calls 4

RunDSLFunction · 0.92
StringEnumBodyDSLFunction · 0.92
buildBodyTypesFunction · 0.85
nameFromRefFunction · 0.85

Tested by

no test coverage detected