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

Function TestParseCopyLine

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

Source from the content-addressed store, hash-verified

2807
2808 copySQL := BuildDuckDBCopyFromSQL("copy_large_record_test", "", path, &CopyFromOptions{
2809 Delimiter: "\t",
2810 NullString: "\\N",
2811 })
2812 if _, err = db.Exec(copySQL); err != nil {
2813 t.Fatalf("COPY 11 MiB record: %v", err)
2814 }
2815
2816 var storedSize int64
2817 if err = db.QueryRow("SELECT length(payload) FROM copy_large_record_test").Scan(&storedSize); err != nil {
2818 t.Fatalf("query copied payload size: %v", err)
2819 }
2820 if storedSize != payloadSize {
2821 t.Fatalf("copied payload size = %d, want %d", storedSize, payloadSize)
2822 }
2823}
2824
2825func TestCopyCommandTypeDetection(t *testing.T) {
2826 c := &clientConn{}
2827
2828 tests := []struct {
2829 name string
2830 query string
2831 expected string
2832 }{
2833 {
2834 name: "COPY TO STDOUT",
2835 query: "COPY users TO STDOUT",
2836 expected: "COPY",
2837 },
2838 {
2839 name: "COPY FROM STDIN",
2840 query: "COPY users FROM STDIN",
2841 expected: "COPY",
2842 },
2843 {
2844 name: "COPY with options",
2845 query: "COPY users FROM STDIN WITH (FORMAT CSV)",
2846 expected: "COPY",
2847 },
2848 {
2849 name: "lowercase copy",
2850 query: "copy users to stdout",
2851 expected: "COPY",
2852 },
2853 }
2854
2855 for _, tt := range tests {
2856 t.Run(tt.name, func(t *testing.T) {
2857 result := c.getCommandType(strings.ToUpper(tt.query))
2858 if result != tt.expected {
2859 t.Errorf("getCommandType(%q) = %q, want %q", tt.query, result, tt.expected)
2860 }
2861 })
2862 }
2863}
2864
2865func TestParseCopyLine(t *testing.T) {
2866 c := &clientConn{}

Callers

nothing calls this directly

Calls 2

parseCopyLineMethod · 0.95
RunMethod · 0.65

Tested by

no test coverage detected