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

Function TestHandleExtractMetadata_AggregateFunctions

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

Source from the content-addressed store, hash-verified

547}
548
549func TestHandleExtractMetadata_AggregateFunctions(t *testing.T) {
550 ctx := context.Background()
551 req := makeReq(map[string]any{
552 "sql": "SELECT COUNT(*), SUM(amount), AVG(price), MIN(id), MAX(id) FROM orders",
553 })
554 res, err := handleExtractMetadata(ctx, req)
555 if err != nil {
556 t.Fatalf("unexpected error: %v", err)
557 }
558 data := unmarshalResult(t, res)
559 functions, ok := data["functions"].([]any)
560 if !ok {
561 t.Fatalf("expected functions to be []any, got %T", data["functions"])
562 }
563 fnSet := make(map[string]bool)
564 for _, fn := range functions {
565 s, ok := fn.(string)
566 if !ok {
567 t.Fatalf("expected function name to be string, got %T", fn)
568 }
569 fnSet[s] = true
570 }
571 for _, expected := range []string{"COUNT", "SUM", "AVG", "MIN", "MAX"} {
572 if !fnSet[expected] {
573 t.Errorf("expected function %q in functions, got %v", expected, functions)
574 }
575 }
576}
577
578func TestHandleSecurityScan_TautologyAttack(t *testing.T) {
579 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