MCPcopy Create free account
hub / github.com/PostHog/duckgres / TestCopyCommandTypeDetection

Function TestCopyCommandTypeDetection

server/conn_test.go:2769–2807  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

2767 }
2768}
2769
2770func TestBuildDuckDBCopyFromSQLAllowsLargeRecord(t *testing.T) {
2771 const payloadSize = 11 << 20
2772
2773 db, err := sql.Open("duckdb", ":memory:")
2774 if err != nil {
2775 t.Fatalf("open duckdb: %v", err)
2776 }
2777 defer func() { _ = db.Close() }()
2778
2779 if _, err = db.Exec("SET memory_limit = '878 MiB'"); err != nil {
2780 t.Fatalf("set worker memory limit: %v", err)
2781 }
2782 if _, err = db.Exec("CREATE TABLE copy_large_record_test (payload TEXT)"); err != nil {
2783 t.Fatalf("create table: %v", err)
2784 }
2785
2786 path := t.TempDir() + "/large-record.tsv"
2787 payload := strings.Repeat("x", payloadSize)
2788 if err = os.WriteFile(path, []byte(payload+"\n"), 0o600); err != nil {
2789 t.Fatalf("write COPY input: %v", err)
2790 }
2791
2792 copySQL := BuildDuckDBCopyFromSQL("copy_large_record_test", "", path, &CopyFromOptions{
2793 Delimiter: "\t",
2794 NullString: "\\N",
2795 })
2796 if _, err = db.Exec(copySQL); err != nil {
2797 t.Fatalf("COPY 11 MiB record: %v", err)
2798 }
2799
2800 var storedSize int64
2801 if err = db.QueryRow("SELECT length(payload) FROM copy_large_record_test").Scan(&storedSize); err != nil {
2802 t.Fatalf("query copied payload size: %v", err)
2803 }
2804 if storedSize != payloadSize {
2805 t.Fatalf("copied payload size = %d, want %d", storedSize, payloadSize)
2806 }
2807}
2808
2809func TestCopyCommandTypeDetection(t *testing.T) {
2810 c := &clientConn{}

Callers

nothing calls this directly

Calls 2

getCommandTypeMethod · 0.95
RunMethod · 0.65

Tested by

no test coverage detected