Add validation tests for query optimizations

Co-authored-by: muhlemmer <5411563+muhlemmer@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2025-08-04 23:07:15 +00:00
parent bcae53a4f3
commit 111db6fc87

View File

@@ -102,3 +102,19 @@ func TestQueries_ActiveIntrospectionClientByID(t *testing.T) {
}) })
} }
} }
// TestIntrospectionQueryOptimizations validates that the optimized query
// has the expected performance characteristics
func TestIntrospectionQueryOptimizations(t *testing.T) {
// Test that UNION ALL is used instead of UNION
assert.Contains(t, introspectionClientByIDQuery, "union all", "Expected 'union all' in optimized query")
// Test that aliases are used consistently
assert.Contains(t, introspectionClientByIDQuery, "from config c", "Expected consistent alias usage 'config c'")
// Test that keys CTE is simplified
assert.Contains(t, introspectionClientByIDQuery, "$2::text as client_id", "Expected simplified keys CTE with $2::text casting")
// Test that conditional join logic is present
assert.Contains(t, introspectionClientByIDQuery, "and $3 = true", "Expected conditional join logic 'and $3 = true'")
}