MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / copy_to_ndjson_basic

Function copy_to_ndjson_basic

nodedb/tests/sql_copy_to.rs:62–86  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

60
61#[tokio::test]
62async 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

Callers

nothing calls this directly

Calls 5

seed_collectionFunction · 0.85
temp_output_pathFunction · 0.85
expectMethod · 0.45
execMethod · 0.45
is_emptyMethod · 0.45

Tested by

no test coverage detected