()
| 109 | |
| 110 | #[tokio::test] |
| 111 | async fn copy_to_csv_with_header() { |
| 112 | let srv = TestServer::start().await; |
| 113 | |
| 114 | seed_collection(&srv, "copy_to_csv_hdr").await; |
| 115 | |
| 116 | let (_dir, out_path) = temp_output_path(".csv"); |
| 117 | srv.exec(&format!( |
| 118 | "COPY copy_to_csv_hdr TO '{out_path}' WITH (FORMAT csv, HEADER true)" |
| 119 | )) |
| 120 | .await |
| 121 | .expect("COPY TO CSV with header"); |
| 122 | |
| 123 | let content = std::fs::read_to_string(&out_path).expect("read output file"); |
| 124 | let lines: Vec<&str> = content.lines().collect(); |
| 125 | // First line is the header. |
| 126 | assert!(!lines.is_empty(), "expected at least a header line"); |
| 127 | // Should have header + 3 data rows. |
| 128 | assert_eq!(lines.len(), 4, "expected header + 3 rows"); |
| 129 | } |
| 130 | |
| 131 | // ── test 4: CSV without header ─────────────────────────────────────────────── |
| 132 |
nothing calls this directly
no test coverage detected