Skip to content

Commit

Permalink
Add tests methods
Browse files Browse the repository at this point in the history
  • Loading branch information
DmitryAstafyev committed Dec 6, 2024
1 parent 68d34ce commit e005959
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 3 deletions.
1 change: 1 addition & 0 deletions application/apps/rustcore/rs-bindings/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions application/apps/rustcore/rs-bindings/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ thiserror = "1.0"
tokio = { version = "1.24", features = ["full"] }
tokio-util = "0.7"
uuid = { version = "1.3", features = ["serde", "v4"] }
serde_json = "1.0"

merging = { path = "../../indexer/merging" }
processor = { path = "../../indexer/processor" }
Expand Down
33 changes: 30 additions & 3 deletions application/apps/rustcore/rs-bindings/src/js/session/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -452,12 +452,11 @@ impl RustSession {

#[node_bindgen]
async fn get_sources_definitions(&self) -> Result<stypes::Sources, stypes::ComputationError> {
Ok(self
.session
self.session
.as_ref()
.ok_or(stypes::ComputationError::SessionUnavailable)?
.get_sources()
.await?)
.await
}

#[node_bindgen]
Expand Down Expand Up @@ -682,4 +681,32 @@ impl RustSession {
.trigger_tracker_error()
.await
}

#[node_bindgen]
fn test_grab_els_as_json(&self) -> Result<String, stypes::ComputationError> {
let mut els = Vec::new();
for pos in 0..50 {
els.push(stypes::GrabbedElement {
source_id: 0,
nature: 0,
content: format!("{pos}Test line content:{}", " test ".repeat(pos + 1)),
pos,
})
}
serde_json::to_string(&els).map_err(|_| stypes::ComputationError::InvalidData)
}

#[node_bindgen]
fn test_grab_els_as_bin(&self) -> Result<stypes::GrabbedElementList, stypes::ComputationError> {
let mut els = Vec::new();
for pos in 0..50 {
els.push(stypes::GrabbedElement {
source_id: 0,
nature: 0,
content: format!("{pos}Test line content:{}", " test ".repeat(pos + 1)),
pos,
})
}
Ok(stypes::GrabbedElementList(els))
}
}

0 comments on commit e005959

Please sign in to comment.