MCPcopy Create free account
hub / github.com/bytebase/bytebase / TestGetSchema_TruncatedAt201

Function TestGetSchema_TruncatedAt201

backend/api/mcp/tool_schema_test.go:610–633  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

608}
609
610func TestGetSchema_TruncatedAt201(t *testing.T) {
611 // Build 201 tables; the 201st sorted entry should be dropped.
612 tables := make([]map[string]any, schemaTableLimit+1)
613 for i := range tables {
614 tables[i] = makeTable(fmt.Sprintf("t%03d", i), 0, []map[string]any{makeColumn("id", "int4", false)}, nil)
615 }
616 resp := makeMetadataResponse(makeSchema("public", tables...))
617 s, _ := mockMetadataServer(t, employeeDB(), resp)
618
619 _, structured, err := s.handleGetSchema(testContext(), nil, SchemaInput{
620 Database: "employee_db",
621 Include: "columns",
622 })
623 require.NoError(t, err)
624 output, ok := structured.(*SchemaOutput)
625 require.True(t, ok)
626 section := output.Schemas[0]
627 require.Len(t, section.Tables, schemaTableLimit)
628 require.True(t, section.Truncated)
629 require.Equal(t, schemaTableLimit, section.TablesShown)
630 // The names are t000..t200; sorted alphabetically the 201st (last) is t200,
631 // which should be dropped. Remaining last table is t199.
632 require.Equal(t, "t199", section.Tables[schemaTableLimit-1].Name)
633}
634
635func TestGetSchema_PerSchemaLimitSemantics(t *testing.T) {
636 // Build 3 schemas with 201 tables each (enough to trigger truncation in each).

Callers

nothing calls this directly

Calls 10

makeMetadataResponseFunction · 0.85
mockMetadataServerFunction · 0.85
employeeDBFunction · 0.85
testContextFunction · 0.85
handleGetSchemaMethod · 0.80
LenMethod · 0.80
makeTableFunction · 0.70
makeColumnFunction · 0.70
makeSchemaFunction · 0.70
EqualMethod · 0.65

Tested by

no test coverage detected