MCPcopy
hub / github.com/sqldef/sqldef / TestCreateFunctionWithPgquery

Function TestCreateFunctionWithPgquery

database/postgres/parser_test.go:118–145  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

116}
117
118func TestCreateFunctionWithPgquery(t *testing.T) {
119 t.Setenv("PSQLDEF_PARSER", "pgquery")
120 postgresParser := NewParser()
121
122 statements, err := postgresParser.Parse(`
123 CREATE FUNCTION increment(i integer) RETURNS integer
124 LANGUAGE plpgsql
125 AS $$
126 BEGIN
127 RETURN i + 1;
128 END;
129 $$;
130 `)
131
132 if err != nil {
133 t.Fatalf("failed to parse CREATE FUNCTION: %v", err)
134 }
135
136 if len(statements) != 1 {
137 t.Fatalf("expected 1 statement, got %d", len(statements))
138 }
139
140 funcStmt := statements[0].Statement
141 _, ok := funcStmt.(*parser.Ignore)
142 if !ok {
143 t.Errorf("expected Ignore, got %T", funcStmt)
144 }
145}
146
147func TestCreateFunctionAutoModeFallbackRetry(t *testing.T) {
148 // Force Auto mode regardless of an ambient PSQLDEF_PARSER (the dev/CI default

Callers

nothing calls this directly

Calls 4

ParseMethod · 0.95
NewParserFunction · 0.70
FatalfMethod · 0.65
ErrorfMethod · 0.65

Tested by

no test coverage detected