mod auth_admin_tests;
mod batch_window_tests;
mod context_cursor_tests;
mod edge_tests;
mod freeze_compaction_tests;
mod group_window_tests;
mod layout_version_tests;
mod schema_tests;
mod serial_tests;
mod staged_txn_tests;
mod string_id_tests;
mod vertex_tests;
use crate::{
GraphStorage, PersistenceConfig, PropertyGraphConfig, ScanOptions, StorageAdmin,
StorageAuthOps, StorageCommitOps, StorageOperationContext, StorageOperationContextOps,
StoragePersistenceOps, StorageReader, StorageSchemaOps, StorageWriter,
};
use linkrs_core::types::{
AutoCompactConfig, EdgeTypeInfo, Index, IndexConfig, IndexField, IndexType, PropertyDef,
SpaceInfo, Timestamp, UserInfo, VertexId,
};
use linkrs_core::vertex_edge_path::Tag;
use linkrs_core::DataType;
use linkrs_core::{Edge, EdgeDirection, RoleType, Value, Vertex};
pub(super) fn create_test_storage() -> GraphStorage {
GraphStorage::new().expect("Failed to create GraphStorage")
}
pub(super) fn create_persistent_storage() -> (tempfile::TempDir, GraphStorage) {
let temp_dir = tempfile::TempDir::new().expect("Failed to create temp dir");
let storage = GraphStorage::new_with_path(temp_dir.path().to_path_buf())
.expect("Failed to create persistent GraphStorage");
(temp_dir, storage)
}
pub(super) fn setup_space(storage: &mut GraphStorage) -> u64 {
let mut space = SpaceInfo::new("test_space".to_string())
.with_vid_type(DataType::BigInt)
.with_comment(Some("test".to_string()));
storage.create_space(&mut space).unwrap();
storage.get_space_id("test_space").unwrap()
}
pub(super) fn setup_person_tag(storage: &mut GraphStorage) -> u32 {
let tag = linkrs_core::types::TagInfo::new("Person".to_string()).with_properties(vec![
PropertyDef::new("id".into(), DataType::BigInt),
PropertyDef::new("name".into(), DataType::String),
PropertyDef::new("age".into(), DataType::BigInt),
]);
storage
.create_tag("test_space", &tag)
.expect("Failed to create tag")
}
pub(super) fn setup_knows_edge(storage: &mut GraphStorage) -> u32 {
let edge = EdgeTypeInfo::new("KNOWS".to_string())
.with_properties(vec![PropertyDef::new("since".into(), DataType::Int)]);
storage
.create_edge_type("test_space", &edge)
.expect("Failed to create edge type")
}
pub(super) fn insert_test_vertex(storage: &mut GraphStorage, id: i64, name: &str) {
let vertex = Vertex::new(
VertexId::try_from_int64(id).expect("test vertex id"),
linkrs_core::vertex_edge_path::Tag::new(
"Person".to_string(),
vec![
("id".into(), Value::BigInt(id)),
("name".into(), Value::string(name)),
]
.into_iter()
.collect(),
),
);
storage.insert_vertex("test_space", vertex).unwrap();
}
pub(super) fn setup_string_id_space(storage: &mut GraphStorage) {
let mut space = SpaceInfo::new("str_space".to_string()).with_vid_type(DataType::String);
storage.create_space(&mut space).unwrap();
let tag = linkrs_core::types::TagInfo::new("Node".to_string()).with_properties(vec![
PropertyDef::new("id".into(), DataType::String),
PropertyDef::new("name".into(), DataType::String),
]);
storage.create_tag("str_space", &tag).unwrap();
let edge = EdgeTypeInfo::new("LINK".to_string());
storage.create_edge_type("str_space", &edge).unwrap();
}
pub(super) fn setup_serial_person_tag(storage: &mut GraphStorage) -> u32 {
let tag = linkrs_core::types::TagInfo::new("Person".to_string()).with_properties(vec![
PropertyDef::new("vid".into(), DataType::BigInt),
PropertyDef::new("id".into(), DataType::BigInt).with_serial(true),
PropertyDef::new("name".into(), DataType::String),
]);
storage
.create_tag("test_space", &tag)
.expect("Failed to create tag")
}
pub(super) fn insert_serial_vertex(storage: &mut GraphStorage, vid: i64, name: &str) {
let vertex = Vertex::new(
VertexId::try_from_int64(vid).expect("test vertex id"),
Tag::new(
"Person".to_string(),
vec![("name".into(), Value::string(name))]
.into_iter()
.collect(),
),
);
storage.insert_vertex("test_space", vertex).unwrap();
}