graph_api_test/index/
vertex_full_text.rs1use crate::{Edge, PersonMut, Vertex, assert_elements_eq, populate_graph};
2use graph_api_lib::{Graph, SupportsVertexFullTextIndex, VertexReferenceMut};
3
4pub fn test_index<T>(graph: &mut T)
11where
12 T: Graph<Vertex = Vertex, Edge = Edge> + SupportsVertexFullTextIndex,
13{
14 let refs = populate_graph(graph);
15 let collected = graph
16 .walk()
17 .vertices(Vertex::person_by_biography("graph"))
18 .collect::<Vec<_>>();
19 assert_elements_eq!(graph, collected, vec![refs.bryn]);
20 graph.remove_vertex(refs.bryn);
21}
22
23pub fn test_index_remove<T>(graph: &mut T)
30where
31 T: Graph<Vertex = Vertex, Edge = Edge> + SupportsVertexFullTextIndex,
32{
33 let refs = populate_graph(graph);
34 graph.remove_vertex(refs.bryn);
35 assert_eq!(
36 graph
37 .walk()
38 .vertices(Vertex::person_by_biography("graph"))
39 .count(),
40 0
41 );
42}
43
44pub fn test_index_update<T>(graph: &mut T)
54where
55 T: Graph<Vertex = Vertex, Edge = Edge> + SupportsVertexFullTextIndex,
56{
57 let refs = populate_graph(graph);
58 graph
59 .vertex_mut(refs.bryn)
60 .expect("bryn must exist")
61 .project_mut::<PersonMut<_, _>>()
62 .expect("must be a person")
63 .set_biography("Developed a graphql proxy in Rust".to_string());
64 assert_eq!(
65 graph
66 .walk()
67 .vertices(Vertex::person_by_biography("graph"))
68 .count(),
69 0
70 );
71 assert_eq!(
72 graph
73 .walk()
74 .vertices(Vertex::person_by_biography("proxy"))
75 .count(),
76 1
77 );
78}