()
| 60 | |
| 61 | #[tokio::test] |
| 62 | async fn copy_to_ndjson_basic() { |
| 63 | let srv = TestServer::start().await; |
| 64 | |
| 65 | seed_collection(&srv, "copy_to_ndjson").await; |
| 66 | |
| 67 | let (_dir, out_path) = temp_output_path(".ndjson"); |
| 68 | srv.exec(&format!("COPY copy_to_ndjson TO '{out_path}'")) |
| 69 | .await |
| 70 | .expect("COPY TO NDJSON"); |
| 71 | |
| 72 | let content = std::fs::read_to_string(&out_path).expect("read output file"); |
| 73 | // Each line must be a valid JSON object. |
| 74 | let mut count = 0usize; |
| 75 | for line in content.lines() { |
| 76 | let line = line.trim(); |
| 77 | if line.is_empty() { |
| 78 | continue; |
| 79 | } |
| 80 | let v: serde_json::Value = serde_json::from_str(line) |
| 81 | .unwrap_or_else(|e| panic!("invalid NDJSON line: {line}: {e}")); |
| 82 | assert!(v.is_object(), "expected JSON object per line"); |
| 83 | count += 1; |
| 84 | } |
| 85 | assert_eq!(count, 3, "expected 3 rows in NDJSON output"); |
| 86 | } |
| 87 | |
| 88 | // ── test 2: JSON array export ──────────────────────────────────────────────── |
| 89 |
nothing calls this directly
no test coverage detected