1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
//! Regression test for native backend edge insertion JSON parsing panic
//!
//! This test reproduces the ConnectionError("expected value at line 1 column 1")
//! that occurs during edge insertion in the native backend when V2 atomic commit
//! protocol is enabled (which is the default for new files).
use sqlitegraph::{EdgeSpec, GraphConfig, NodeSpec, open_graph};
use tempfile::tempdir;
#[test]
fn test_native_edge_insertion_regression() -> Result<(), Box<dyn std::error::Error>> {
// This test reproduces the exact panic that occurs in the benchmark
// when inserting edges into a native backend graph.
let temp_dir = tempdir()?;
let db_path = temp_dir.path().join("regression_test.db");
// Create native backend graph (V2 atomic commit is enabled by default)
let graph = open_graph(&db_path, &GraphConfig::native())?;
// Create two nodes
let node1 = graph.insert_node(NodeSpec {
kind: "Test".to_string(),
name: "node1".to_string(),
file_path: None,
data: serde_json::json!({"id": 1}),
})?;
let node2 = graph.insert_node(NodeSpec {
kind: "Test".to_string(),
name: "node2".to_string(),
file_path: None,
data: serde_json::json!({"id": 2}),
})?;
// This edge insertion should NOT fail with:
// ConnectionError("expected value at line 1 column 1")
let edge_id = graph.insert_edge(EdgeSpec {
from: node1,
to: node2,
edge_type: "test".to_string(),
data: serde_json::json!({"order": 1}),
})?;
// If we get here, the bug is fixed
assert!(edge_id > 0);
Ok(())
}