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

Function TestRenderCreateTable_AllFeatures

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

Source from the content-addressed store, hash-verified

342}
343
344func TestRenderCreateTable_AllFeatures(t *testing.T) {
345 stmt := &ast.CreateTableStatement{
346 Name: "t",
347 Temporary: true,
348 IfNotExists: true,
349 Columns: []ast.ColumnDef{
350 {Name: "id", Type: "INT"},
351 {Name: "name", Type: "TEXT"},
352 },
353 Constraints: []ast.TableConstraint{
354 {Type: "PRIMARY KEY", Columns: []string{"id"}},
355 },
356 Inherits: []string{"parent"},
357 PartitionBy: &ast.PartitionBy{Type: "HASH", Columns: []string{"id"}},
358 Options: []ast.TableOption{{Name: "engine", Value: "InnoDB"}},
359 }
360
361 readable := fmtStmt(stmt, ast.ReadableStyle())
362 for _, want := range []string{"CREATE TEMPORARY TABLE IF NOT EXISTS", "INHERITS", "PARTITION BY"} {
363 if !strings.Contains(readable, want) {
364 t.Errorf("missing %q in readable: %s", want, readable)
365 }
366 }
367
368 compact := fmtStmt(stmt, ast.CompactStyle())
369 if strings.Contains(compact, "\n") {
370 t.Errorf("compact should be single line: %s", compact)
371 }
372}
373
374func TestRenderCreateTable_Nil(t *testing.T) {
375 var stmt *ast.CreateTableStatement

Callers

nothing calls this directly

Calls 4

ReadableStyleFunction · 0.92
CompactStyleFunction · 0.92
fmtStmtFunction · 0.85
ErrorfMethod · 0.65

Tested by

no test coverage detected