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

Function TestDropStatementPool

pkg/sql/ast/pool_ddl_test.go:519–566  ·  view source on GitHub ↗

============================================================ DropStatement pool tests ============================================================

(t *testing.T)

Source from the content-addressed store, hash-verified

517// ============================================================
518
519func TestDropStatementPool(t *testing.T) {
520 t.Run("Get returns non-nil", func(t *testing.T) {
521 stmt := GetDropStatement()
522 if stmt == nil {
523 t.Fatal("GetDropStatement() returned nil")
524 }
525 PutDropStatement(stmt)
526 })
527
528 t.Run("Put nil is safe", func(t *testing.T) {
529 PutDropStatement(nil)
530 })
531
532 t.Run("Fields zeroed after Put", func(t *testing.T) {
533 stmt := GetDropStatement()
534 stmt.ObjectType = "TABLE"
535 stmt.IfExists = true
536 stmt.Names = append(stmt.Names, "users", "orders")
537 stmt.CascadeType = "CASCADE"
538
539 PutDropStatement(stmt)
540
541 if stmt.ObjectType != "" {
542 t.Errorf("ObjectType not cleared, got %q", stmt.ObjectType)
543 }
544 if stmt.IfExists {
545 t.Error("IfExists not cleared")
546 }
547 if len(stmt.Names) != 0 {
548 t.Errorf("Names not cleared, len=%d", len(stmt.Names))
549 }
550 if stmt.CascadeType != "" {
551 t.Errorf("CascadeType not cleared, got %q", stmt.CascadeType)
552 }
553 })
554
555 t.Run("Pool roundtrip reuse", func(t *testing.T) {
556 stmt1 := GetDropStatement()
557 stmt1.ObjectType = "VIEW"
558 PutDropStatement(stmt1)
559
560 stmt2 := GetDropStatement()
561 if stmt2.ObjectType != "" {
562 t.Errorf("Reused statement not clean, ObjectType=%q", stmt2.ObjectType)
563 }
564 PutDropStatement(stmt2)
565 })
566}
567
568// ============================================================
569// TruncateStatement pool tests

Callers

nothing calls this directly

Calls 5

GetDropStatementFunction · 0.85
PutDropStatementFunction · 0.85
RunMethod · 0.80
ErrorfMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected