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

Function TestMemoryManagement

cmd/gosqlx/cmd/integration_test.go:270–302  ·  view source on GitHub ↗

TestMemoryManagement tests that AST objects are properly released

(t *testing.T)

Source from the content-addressed store, hash-verified

268
269// TestMemoryManagement tests that AST objects are properly released
270func TestMemoryManagement(t *testing.T) {
271 // This test verifies our memory management improvements don't crash
272 // Note: Actual memory leak detection would require more sophisticated tooling
273
274 testSQL := "SELECT id, name FROM users WHERE active = true"
275
276 t.Run("AnalyzeMemoryManagement", func(t *testing.T) {
277 // This should not crash or leak memory
278 result, err := DetectAndReadInput(testSQL)
279 if err != nil {
280 t.Fatalf("Input detection failed: %v", err)
281 }
282
283 if result.Type != InputTypeSQL {
284 t.Errorf("Expected SQL input type, got: %v", result.Type)
285 }
286
287 // The analyze workflow would continue here, but we're testing
288 // that the input processing doesn't cause issues
289 })
290
291 t.Run("ParseMemoryManagement", func(t *testing.T) {
292 // Similar test for parse command workflow
293 result, err := DetectAndReadInput(testSQL)
294 if err != nil {
295 t.Fatalf("Input detection failed: %v", err)
296 }
297
298 if len(result.Content) == 0 {
299 t.Error("Expected non-empty content")
300 }
301 })
302}
303
304// TestSecurityLimits tests the security improvements
305func TestSecurityLimits(t *testing.T) {

Callers

nothing calls this directly

Calls 5

RunMethod · 0.80
DetectAndReadInputFunction · 0.70
FatalfMethod · 0.65
ErrorfMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected