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

Function TestTruncateSQL

pkg/gosqlx/testing/testing_test.go:481–495  ·  view source on GitHub ↗

Test truncateSQL helper

(t *testing.T)

Source from the content-addressed store, hash-verified

479
480// Test truncateSQL helper
481func TestTruncateSQL(t *testing.T) {
482 shortSQL := "SELECT * FROM users"
483 if truncated := truncateSQL(shortSQL); truncated != shortSQL {
484 t.Errorf("Short SQL should not be truncated, got: %s", truncated)
485 }
486
487 longSQL := strings.Repeat("SELECT * FROM users WHERE active = true AND ", 10)
488 truncated := truncateSQL(longSQL)
489 if len(truncated) > 104 { // 100 chars + "..."
490 t.Errorf("Long SQL should be truncated to max 104 chars, got: %d", len(truncated))
491 }
492 if !strings.HasSuffix(truncated, "...") {
493 t.Error("Truncated SQL should end with '...'")
494 }
495}
496
497// Test extractTables helper with various SQL statements
498func TestExtractTables_SelectWithJoins(t *testing.T) {

Callers

nothing calls this directly

Calls 3

truncateSQLFunction · 0.85
ErrorfMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected