graph_api_test/index/
vertex_full_text.rs1#[cfg(feature = "vertex-full-text-index")]
2use crate::{PersonMut, assert_elements_eq, populate_graph};
3#[cfg(feature = "vertex-full-text-index")]
4use graph_api_lib::VertexReferenceMut;
5
6use crate::{Edge, Vertex};
7use graph_api_lib::Graph;
8
9#[cfg(feature = "vertex-full-text-index")]
16pub fn test_index<T>(graph: &mut T)
17where
18 T: Graph<Vertex = Vertex, Edge = Edge> + graph_api_lib::SupportsVertexFullTextIndex,
19{
20 let refs = populate_graph(graph);
21 let collected = graph
22 .walk()
23 .vertices(Vertex::person_by_biography("graph"))
24 .collect::<Vec<_>>();
25 assert_elements_eq!(graph, collected, vec![refs.bryn]);
26}
27#[cfg(not(feature = "vertex-full-text-index"))]
28pub fn test_index<T>(_graph: &mut T)
29where
30 T: Graph<Vertex = Vertex, Edge = Edge>,
31{
32}
33
34#[cfg(all(feature = "vertex-full-text-index", feature = "element-removal"))]
41pub fn test_index_remove<T>(graph: &mut T)
42where
43 T: Graph<Vertex = Vertex, Edge = Edge>
44 + graph_api_lib::SupportsVertexFullTextIndex
45 + graph_api_lib::SupportsElementRemoval,
46{
47 let refs = populate_graph(graph);
48 graph.remove_vertex(refs.bryn);
49 assert_eq!(
50 graph
51 .walk()
52 .vertices(Vertex::person_by_biography("graph"))
53 .count(),
54 0
55 );
56}
57
58#[cfg(not(all(feature = "vertex-full-text-index", feature = "element-removal")))]
59pub fn test_index_remove<T>(_graph: &mut T)
60where
61 T: Graph<Vertex = Vertex, Edge = Edge>,
62{
63}
64
65#[cfg(feature = "vertex-full-text-index")]
75pub fn test_index_update<T>(graph: &mut T)
76where
77 T: Graph<Vertex = Vertex, Edge = Edge> + graph_api_lib::SupportsVertexFullTextIndex,
78{
79 let refs = populate_graph(graph);
80 graph
81 .vertex_mut(refs.bryn)
82 .expect("bryn must exist")
83 .project_mut::<PersonMut<_, _>>()
84 .expect("must be a person")
85 .set_biography("Developed a graphql proxy in Rust".to_string());
86 assert_eq!(
87 graph
88 .walk()
89 .vertices(Vertex::person_by_biography("graph"))
90 .count(),
91 0
92 );
93 assert_eq!(
94 graph
95 .walk()
96 .vertices(Vertex::person_by_biography("proxy"))
97 .count(),
98 1
99 );
100}
101
102#[cfg(not(feature = "vertex-full-text-index"))]
103pub fn test_index_update<T>(_graph: &mut T)
104where
105 T: Graph<Vertex = Vertex, Edge = Edge>,
106{
107}