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

Function TestEncoder_Encode_NilOpenAPI

protocol/triple/openapi/encoder_test.go:31–49  ·  view source on GitHub ↗

--- Encode tests ---

(t *testing.T)

Source from the content-addressed store, hash-verified

29
30// --- Encode tests ---
31func TestEncoder_Encode_NilOpenAPI(t *testing.T) {
32 e := NewEncoder()
33 result, err := e.Encode(nil, "json", false)
34 if err != nil {
35 t.Fatalf("unexpected error: %v", err)
36 }
37 if result == "" {
38 t.Error("result should not be empty")
39 }
40
41 // Should produce valid JSON with default OpenAPI structure
42 var parsed map[string]any
43 if err := json.Unmarshal([]byte(result), &parsed); err != nil {
44 t.Fatalf("result should be valid JSON: %v", err)
45 }
46 if v, ok := parsed["openapi"]; !ok || v != model.OpenAPIVersion30 {
47 t.Errorf("openapi version = %v, want %s", v, model.OpenAPIVersion30)
48 }
49}
50
51func TestEncoder_Encode_JSONPretty(t *testing.T) {
52 e := NewEncoder()

Callers

nothing calls this directly

Calls 6

EncodeMethod · 0.95
NewEncoderFunction · 0.85
FatalfMethod · 0.65
ErrorMethod · 0.65
UnmarshalMethod · 0.65
ErrorfMethod · 0.65

Tested by

no test coverage detected