drasi_bootstrap_scriptfile/lib.rs
1// Copyright 2025 The Drasi Authors.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15//! ScriptFile bootstrap plugin for Drasi
16//!
17//! This plugin provides the ScriptFile bootstrap provider implementation for reading
18//! bootstrap data from JSONL script files.
19//!
20//! # Example
21//!
22//! ```no_run
23//! use drasi_bootstrap_scriptfile::ScriptFileBootstrapProvider;
24//!
25//! // Using the builder
26//! let provider = ScriptFileBootstrapProvider::builder()
27//! .with_file("/path/to/data.jsonl")
28//! .with_file("/path/to/more_data.jsonl")
29//! .build();
30//!
31//! // Or using configuration
32//! use drasi_lib::bootstrap::ScriptFileBootstrapConfig;
33//!
34//! let config = ScriptFileBootstrapConfig {
35//! file_paths: vec!["/path/to/data.jsonl".to_string()],
36//! };
37//! let provider = ScriptFileBootstrapProvider::new(config);
38//!
39//! // Or using with_paths directly
40//! let provider = ScriptFileBootstrapProvider::with_paths(vec![
41//! "/path/to/data.jsonl".to_string()
42//! ]);
43//! ```
44
45pub mod script_file;
46pub mod script_reader;
47pub mod script_types;
48
49pub use drasi_lib::bootstrap::ScriptFileBootstrapConfig;
50pub use script_file::{ScriptFileBootstrapProvider, ScriptFileBootstrapProviderBuilder};
51
52#[cfg(test)]
53mod tests {
54 use super::*;
55
56 #[test]
57 fn test_scriptfile_bootstrap_builder_empty() {
58 let provider = ScriptFileBootstrapProviderBuilder::new().build();
59 // Provider created with empty file paths
60 let _ = provider;
61 }
62
63 #[test]
64 fn test_scriptfile_bootstrap_builder_single_file() {
65 let provider = ScriptFileBootstrapProviderBuilder::new()
66 .with_file("/path/to/file.jsonl")
67 .build();
68 let _ = provider;
69 }
70
71 #[test]
72 fn test_scriptfile_bootstrap_builder_multiple_files() {
73 let provider = ScriptFileBootstrapProviderBuilder::new()
74 .with_file("/path/to/file1.jsonl")
75 .with_file("/path/to/file2.jsonl")
76 .with_file("/path/to/file3.jsonl")
77 .build();
78 let _ = provider;
79 }
80
81 #[test]
82 fn test_scriptfile_bootstrap_builder_with_file_paths() {
83 let paths = vec![
84 "/data/nodes.jsonl".to_string(),
85 "/data/relations.jsonl".to_string(),
86 ];
87 let provider = ScriptFileBootstrapProviderBuilder::new()
88 .with_file_paths(paths)
89 .build();
90 let _ = provider;
91 }
92
93 #[test]
94 fn test_scriptfile_bootstrap_from_provider_method() {
95 // Test using ScriptFileBootstrapProvider::builder()
96 let provider = ScriptFileBootstrapProvider::builder()
97 .with_file("/initial/data.jsonl")
98 .build();
99 let _ = provider;
100 }
101
102 #[test]
103 fn test_scriptfile_bootstrap_builder_default() {
104 let provider = ScriptFileBootstrapProviderBuilder::default().build();
105 let _ = provider;
106 }
107
108 #[test]
109 fn test_scriptfile_bootstrap_provider_default() {
110 // ScriptFileBootstrapProvider::default() should work
111 let provider = ScriptFileBootstrapProvider::default();
112 let _ = provider;
113 }
114
115 #[test]
116 fn test_scriptfile_bootstrap_new_with_config() {
117 // Test using ScriptFileBootstrapProvider::new(config)
118 let config = ScriptFileBootstrapConfig {
119 file_paths: vec!["/bootstrap/nodes.jsonl".to_string()],
120 };
121 let provider = ScriptFileBootstrapProvider::new(config);
122 let _ = provider;
123 }
124
125 #[test]
126 fn test_scriptfile_bootstrap_with_paths() {
127 // Test using ScriptFileBootstrapProvider::with_paths()
128 let provider = ScriptFileBootstrapProvider::with_paths(vec![
129 "/bootstrap/nodes.jsonl".to_string(),
130 "/bootstrap/relations.jsonl".to_string(),
131 ]);
132 let _ = provider;
133 }
134}