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

Function TestExtractColumns_Simple

pkg/gosqlx/testing/testing_test.go:537–558  ·  view source on GitHub ↗

Test extractColumns helper

(t *testing.T)

Source from the content-addressed store, hash-verified

535
536// Test extractColumns helper
537func TestExtractColumns_Simple(t *testing.T) {
538 sql := "SELECT id, name, email FROM users"
539 astNode := RequireParse(t, sql)
540
541 columns := extractColumns(astNode)
542 expectedColumns := []string{"id", "name", "email"}
543
544 if len(columns) != len(expectedColumns) {
545 t.Errorf("Expected %d columns, got %d: %v", len(expectedColumns), len(columns), columns)
546 }
547
548 colMap := make(map[string]bool)
549 for _, col := range columns {
550 colMap[col] = true
551 }
552
553 for _, expected := range expectedColumns {
554 if !colMap[expected] {
555 t.Errorf("Expected column '%s' not found in extracted columns: %v", expected, columns)
556 }
557 }
558}
559
560// Test stringSlicesEqual helper
561func TestStringSlicesEqual(t *testing.T) {

Callers

nothing calls this directly

Calls 3

RequireParseFunction · 0.85
extractColumnsFunction · 0.70
ErrorfMethod · 0.65

Tested by

no test coverage detected