Skip to main content

drasi_bootstrap_scriptfile/
lib.rs

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