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

Function TestRenderInsert_WithQuery

pkg/formatter/render_test.go:187–203  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

185}
186
187func TestRenderInsert_WithQuery(t *testing.T) {
188 stmt := &ast.InsertStatement{
189 With: &ast.WithClause{CTEs: []*ast.CommonTableExpr{
190 {Name: "c", Statement: &ast.SelectStatement{Columns: []ast.Expression{&ast.Identifier{Name: "x"}}}},
191 }},
192 TableName: "t",
193 Columns: []ast.Expression{&ast.Identifier{Name: "a"}},
194 Query: &ast.SelectStatement{Columns: []ast.Expression{&ast.Identifier{Name: "x"}}},
195 Returning: []ast.Expression{&ast.Identifier{Name: "id"}},
196 }
197 result := fmtStmt(stmt, ast.ReadableStyle())
198 for _, want := range []string{"WITH", "INSERT INTO", "RETURNING"} {
199 if !strings.Contains(result, want) {
200 t.Errorf("missing %q in: %s", want, result)
201 }
202 }
203}
204
205func TestRenderInsert_OnConflict(t *testing.T) {
206 stmt := &ast.InsertStatement{

Callers

nothing calls this directly

Calls 3

ReadableStyleFunction · 0.92
fmtStmtFunction · 0.85
ErrorfMethod · 0.65

Tested by

no test coverage detected