forked from extern/nushell
Inc refactoring, Value helper test method extractions, and more integration helpers. (#1135)
* Manifests check. Ignore doctests for now. * We continue with refactorings towards the separation of concerns between crates. `nu_plugin_inc` and `nu_plugin_str` common test helpers usage has been refactored into `nu-plugin` value test helpers. Inc also uses the new API for integration tests.
This commit is contained in:
committed by
GitHub
parent
21e508009f
commit
0615adac94
38
crates/nu_plugin_inc/src/lib.rs
Normal file
38
crates/nu_plugin_inc/src/lib.rs
Normal file
@ -0,0 +1,38 @@
|
||||
mod inc;
|
||||
mod nu_plugin_inc;
|
||||
|
||||
pub use inc::Inc;
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::Inc;
|
||||
use crate::inc::Action;
|
||||
use nu_protocol::Value;
|
||||
use nu_value_ext::ValueExt;
|
||||
|
||||
impl Inc {
|
||||
pub fn expect_action(&self, action: Action) {
|
||||
match &self.action {
|
||||
Some(set) if set == &action => {}
|
||||
Some(other) => panic!(format!("\nExpected {:#?}\n\ngot {:#?}", action, other)),
|
||||
None => panic!(format!("\nAction {:#?} not found.", action)),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn expect_field(&self, field: Value) {
|
||||
let field = match field.as_column_path() {
|
||||
Ok(column_path) => column_path,
|
||||
Err(reason) => panic!(format!(
|
||||
"\nExpected {:#?} to be a ColumnPath, \n\ngot {:#?}",
|
||||
field, reason
|
||||
)),
|
||||
};
|
||||
|
||||
match &self.field {
|
||||
Some(column_path) if column_path == &field => {}
|
||||
Some(other) => panic!(format!("\nExpected {:#?} \n\ngot {:#?}", field, other)),
|
||||
None => panic!(format!("\nField {:#?} not found.", field)),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user