MCPcopy Create free account
hub / github.com/ajitpratap0/GoSQLX / TestHandleExtractMetadata_ComplexJoin

Function TestHandleExtractMetadata_ComplexJoin

pkg/mcp/tools_test.go:516–547  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

514}
515
516func TestHandleExtractMetadata_ComplexJoin(t *testing.T) {
517 ctx := context.Background()
518 req := makeReq(map[string]any{
519 "sql": "SELECT a.id, b.name, c.value FROM alpha a JOIN beta b ON a.id = b.alpha_id JOIN gamma c ON b.id = c.beta_id",
520 })
521 res, err := handleExtractMetadata(ctx, req)
522 if err != nil {
523 t.Fatalf("unexpected error: %v", err)
524 }
525 data := unmarshalResult(t, res)
526 tables, ok := data["tables"].([]any)
527 if !ok {
528 t.Fatalf("expected tables to be []any, got %T", data["tables"])
529 }
530 if len(tables) < 3 {
531 t.Errorf("expected at least 3 tables, got %d: %v", len(tables), tables)
532 }
533 // Check that all three table names are present.
534 tableSet := make(map[string]bool)
535 for _, tbl := range tables {
536 s, ok := tbl.(string)
537 if !ok {
538 t.Fatalf("expected table name to be string, got %T", tbl)
539 }
540 tableSet[s] = true
541 }
542 for _, expected := range []string{"alpha", "beta", "gamma"} {
543 if !tableSet[expected] {
544 t.Errorf("expected table %q in tables, got %v", expected, tables)
545 }
546 }
547}
548
549func TestHandleExtractMetadata_AggregateFunctions(t *testing.T) {
550 ctx := context.Background()

Callers

nothing calls this directly

Calls 5

makeReqFunction · 0.85
handleExtractMetadataFunction · 0.85
unmarshalResultFunction · 0.85
FatalfMethod · 0.65
ErrorfMethod · 0.65

Tested by

no test coverage detected