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)
| 14 | // message with only scalar fields. SignupRequest is a good representative — |
| 15 | // string / repeated string / bool / message-typed (AppData). |
| 16 | func 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. |
| 39 | func TestSchemaForMessage_EmptyRequest(t *testing.T) { |
nothing calls this directly
no test coverage detected