Thanks to visit codestin.com
Credit goes to docs.rs

Skip to main content

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#![allow(unexpected_cfgs)]
16
17//! ScriptFile bootstrap plugin for Drasi
18//!
19//! This plugin provides the ScriptFile bootstrap provider implementation for reading
20//! bootstrap data from JSONL script files.
21//!
22//! # Example
23//!
24//! ```no_run
25//! use drasi_bootstrap_scriptfile::ScriptFileBootstrapProvider;
26//!
27//! // Using the builder
28//! let provider = ScriptFileBootstrapProvider::builder()
29//!     .with_file("/path/to/data.jsonl")
30//!     .with_file("/path/to/more_data.jsonl")
31//!     .build();
32//!
33//! // Or using configuration
34//! use drasi_bootstrap_scriptfile::ScriptFileBootstrapConfig;
35//!
36//! let config = ScriptFileBootstrapConfig {
37//!     file_paths: vec!["/path/to/data.jsonl".to_string()],
38//! };
39//! let provider = ScriptFileBootstrapProvider::new(config);
40//!
41//! // Or using with_paths directly
42//! let provider = ScriptFileBootstrapProvider::with_paths(vec![
43//!     "/path/to/data.jsonl".to_string()
44//! ]);
45//! ```
46
47pub mod descriptor;
48pub mod script_file;
49pub mod script_reader;
50pub mod script_types;
51
52pub use drasi_lib::bootstrap::ScriptFileBootstrapConfig;
53pub use script_file::{ScriptFileBootstrapProvider, ScriptFileBootstrapProviderBuilder};
54
55/// Dynamic plugin entry point.
56///
57/// Dynamic plugin entry point.
58#[cfg(feature = "dynamic-plugin")]
59drasi_plugin_sdk::export_plugin!(
60    plugin_id = "scriptfile-bootstrap",
61    core_version = env!("CARGO_PKG_VERSION"),
62    lib_version = env!("CARGO_PKG_VERSION"),
63    plugin_version = env!("CARGO_PKG_VERSION"),
64    source_descriptors = [],
65    reaction_descriptors = [],
66    bootstrap_descriptors = [descriptor::ScriptFileBootstrapDescriptor],
67);
68
69#[cfg(test)]
70mod tests {
71    use super::*;
72
73    #[test]
74    fn test_scriptfile_bootstrap_builder_empty() {
75        let provider = ScriptFileBootstrapProviderBuilder::new().build();
76        // Provider created with empty file paths
77        let _ = provider;
78    }
79
80    #[test]
81    fn test_scriptfile_bootstrap_builder_single_file() {
82        let provider = ScriptFileBootstrapProviderBuilder::new()
83            .with_file("/path/to/file.jsonl")
84            .build();
85        let _ = provider;
86    }
87
88    #[test]
89    fn test_scriptfile_bootstrap_builder_multiple_files() {
90        let provider = ScriptFileBootstrapProviderBuilder::new()
91            .with_file("/path/to/file1.jsonl")
92            .with_file("/path/to/file2.jsonl")
93            .with_file("/path/to/file3.jsonl")
94            .build();
95        let _ = provider;
96    }
97
98    #[test]
99    fn test_scriptfile_bootstrap_builder_with_file_paths() {
100        let paths = vec![
101            "/data/nodes.jsonl".to_string(),
102            "/data/relations.jsonl".to_string(),
103        ];
104        let provider = ScriptFileBootstrapProviderBuilder::new()
105            .with_file_paths(paths)
106            .build();
107        let _ = provider;
108    }
109
110    #[test]
111    fn test_scriptfile_bootstrap_from_provider_method() {
112        // Test using ScriptFileBootstrapProvider::builder()
113        let provider = ScriptFileBootstrapProvider::builder()
114            .with_file("/initial/data.jsonl")
115            .build();
116        let _ = provider;
117    }
118
119    #[test]
120    fn test_scriptfile_bootstrap_builder_default() {
121        let provider = ScriptFileBootstrapProviderBuilder::default().build();
122        let _ = provider;
123    }
124
125    #[test]
126    fn test_scriptfile_bootstrap_provider_default() {
127        // ScriptFileBootstrapProvider::default() should work
128        let provider = ScriptFileBootstrapProvider::default();
129        let _ = provider;
130    }
131
132    #[test]
133    fn test_scriptfile_bootstrap_new_with_config() {
134        // Test using ScriptFileBootstrapProvider::new(config)
135        let config = ScriptFileBootstrapConfig {
136            file_paths: vec!["/bootstrap/nodes.jsonl".to_string()],
137        };
138        let provider = ScriptFileBootstrapProvider::new(config);
139        let _ = provider;
140    }
141
142    #[test]
143    fn test_scriptfile_bootstrap_with_paths() {
144        // Test using ScriptFileBootstrapProvider::with_paths()
145        let provider = ScriptFileBootstrapProvider::with_paths(vec![
146            "/bootstrap/nodes.jsonl".to_string(),
147            "/bootstrap/relations.jsonl".to_string(),
148        ]);
149        let _ = provider;
150    }
151}