MCPcopy Create free account
hub / github.com/GraphLite-AI/GraphLite / new

Method new

graphlite/tests/testutils/test_fixture.rs:37–74  ·  view source on GitHub ↗

Create a new test fixture using ONLY public API

()

Source from the content-addressed store, hash-verified

35
36 /// Create a new test fixture using ONLY public API
37 pub fn new() -> Result<Self, Box<dyn std::error::Error>> {
38 // Create temporary directory
39 let temp_dir = tempfile::tempdir()?;
40 let db_path = temp_dir.path().join("graphlite_test");
41
42 // Use public API - QueryCoordinator::from_path()
43 // This initializes ALL internal components automatically
44 let coordinator =
45 QueryCoordinator::from_path(db_path).map_err(Box::<dyn std::error::Error>::from)?;
46
47 // Create session using public API
48 let session_id = coordinator
49 .create_simple_session("admin")
50 .map_err(Box::<dyn std::error::Error>::from)?;
51
52 // Use a unique schema name for test isolation (prevents concurrent test interference)
53 let schema_name = format!("test_schema_{}", fastrand::u64(..));
54
55 // Create the shared schema if it doesn't exist
56 let _ = coordinator.process_query(
57 &format!("CREATE SCHEMA IF NOT EXISTS /{}", schema_name),
58 &session_id,
59 );
60
61 // Set the schema as the session default
62 let _ =
63 coordinator.process_query(&format!("SESSION SET SCHEMA /{}", schema_name), &session_id);
64
65 let fixture = TestFixture {
66 coordinator,
67 session_id,
68 schema_name,
69 graph_name: None,
70 _temp_dir: temp_dir,
71 };
72
73 Ok(fixture)
74 }
75
76 /// Create test fixture with simple data
77 pub fn with_simple_data() -> Result<Self, Box<dyn std::error::Error>> {

Callers

nothing calls this directly

Calls 2

create_simple_sessionMethod · 0.80
process_queryMethod · 0.80

Tested by

no test coverage detected