MCPcopy Create free account
hub / github.com/authorizerdev/authorizer / TestSchemaForMessage_FlatScalars

Function TestSchemaForMessage_FlatScalars

internal/mcp/schema_test.go:16–36  ·  view source on GitHub ↗

TestSchemaForMessage_FlatScalars covers the most common case: a request message with only scalar fields. SignupRequest is a good representative — string / repeated string / bool / message-typed (AppData).

(t *testing.T)

Source from the content-addressed store, hash-verified

14// message with only scalar fields. SignupRequest is a good representative —
15// string / repeated string / bool / message-typed (AppData).
16func TestSchemaForMessage_FlatScalars(t *testing.T) {
17 md := (&authorizerv1.SignupRequest{}).ProtoReflect().Descriptor()
18 s := schemaForMessage(md)
19
20 assert.Equal(t, "object", s.Type)
21 require.NotNil(t, s.Properties)
22
23 assert.Equal(t, "string", s.Properties["email"].Type)
24 assert.Equal(t, "string", s.Properties["password"].Type)
25 assert.Equal(t, "boolean", s.Properties["is_multi_factor_auth_enabled"].Type)
26
27 // repeated string → array of strings
28 roles := s.Properties["roles"]
29 require.Equal(t, "array", roles.Type)
30 require.NotNil(t, roles.Items)
31 assert.Equal(t, "string", roles.Items.Type)
32
33 // Nested message field (AppData) — recurses into its sub-schema.
34 app := s.Properties["app_data"]
35 assert.Equal(t, "object", app.Type)
36}
37
38// TestSchemaForMessage_EmptyRequest — MetaRequest has no fields.
39func TestSchemaForMessage_EmptyRequest(t *testing.T) {

Callers

nothing calls this directly

Calls 3

schemaForMessageFunction · 0.85
DescriptorMethod · 0.45
ProtoReflectMethod · 0.45

Tested by

no test coverage detected