Remove unwraps (#1153)

* Remove a batch of unwraps

* finish another batch
This commit is contained in:
Jonathan Turner
2020-01-04 10:11:21 +13:00
committed by GitHub
parent 339a2de0eb
commit 5919c6c433
27 changed files with 449 additions and 220 deletions

View File

@ -1,6 +1,7 @@
mod integration {
use crate::inc::{Action, SemVerAction};
use crate::Inc;
use nu_errors::ShellError;
use nu_plugin::test_helpers::value::{column_path, string};
use nu_plugin::test_helpers::{plugin, CallStub};
@ -52,16 +53,21 @@ mod integration {
}
#[test]
fn picks_up_argument_for_field() {
fn picks_up_argument_for_field() -> Result<(), ShellError> {
plugin(&mut Inc::new())
.args(CallStub::new().with_parameter("package.version").create())
.args(CallStub::new().with_parameter("package.version")?.create())
.setup(|plugin, _| {
plugin.expect_field(column_path(&[string("package"), string("version")]))
//FIXME: this will need to be updated
if let Ok(column_path) = column_path(&[string("package"), string("version")]) {
plugin.expect_field(column_path)
}
});
Ok(())
}
mod sem_ver {
use crate::Inc;
use nu_errors::ShellError;
use nu_plugin::test_helpers::value::{get_data, string, structured_sample_record};
use nu_plugin::test_helpers::{expect_return_value_at, plugin, CallStub};
@ -70,12 +76,12 @@ mod integration {
}
#[test]
fn major_input_using_the_field_passed_as_parameter() {
fn major_input_using_the_field_passed_as_parameter() -> Result<(), ShellError> {
let run = plugin(&mut Inc::new())
.args(
CallStub::new()
.with_long_flag("major")
.with_parameter("version")
.with_parameter("version")?
.create(),
)
.input(cargo_sample_record("0.1.3"))
@ -85,15 +91,16 @@ mod integration {
let actual = expect_return_value_at(run, 0);
assert_eq!(get_data(actual, "version"), string("1.0.0"));
Ok(())
}
#[test]
fn minor_input_using_the_field_passed_as_parameter() {
fn minor_input_using_the_field_passed_as_parameter() -> Result<(), ShellError> {
let run = plugin(&mut Inc::new())
.args(
CallStub::new()
.with_long_flag("minor")
.with_parameter("version")
.with_parameter("version")?
.create(),
)
.input(cargo_sample_record("0.1.3"))
@ -103,15 +110,16 @@ mod integration {
let actual = expect_return_value_at(run, 0);
assert_eq!(get_data(actual, "version"), string("0.2.0"));
Ok(())
}
#[test]
fn patch_input_using_the_field_passed_as_parameter() {
fn patch_input_using_the_field_passed_as_parameter() -> Result<(), ShellError> {
let run = plugin(&mut Inc::new())
.args(
CallStub::new()
.with_long_flag("patch")
.with_parameter("version")
.with_parameter("version")?
.create(),
)
.input(cargo_sample_record("0.1.3"))
@ -121,6 +129,7 @@ mod integration {
let actual = expect_return_value_at(run, 0);
assert_eq!(get_data(actual, "version"), string("0.1.4"));
Ok(())
}
}
}