Tests communicate better (separate) plugin wiring vs str features.

This commit is contained in:
Andrés N. Robalino 2019-07-30 12:46:49 -05:00
parent 832c329363
commit e7fb58ef9a

View File

@ -266,53 +266,53 @@ mod tests {
#[test] #[test]
fn str_plugin_configuration_flags_wired() { fn str_plugin_configuration_flags_wired() {
let mut strutils = Str::new(); let mut plugin = Str::new();
let config = strutils.config().unwrap(); let configured = plugin.config().unwrap();
for action_flag in &["downcase", "upcase", "to-int"] { for action_flag in &["downcase", "upcase", "to-int"] {
assert!(config.named.get(*action_flag).is_some()); assert!(configured.named.get(*action_flag).is_some());
} }
} }
#[test] #[test]
fn str_accepts_downcase() { fn str_plugin_accepts_downcase() {
let mut strutils = Str::new(); let mut plugin = Str::new();
assert!(strutils assert!(plugin
.begin_filter(CallStub::new().with_long_flag("downcase").create()) .begin_filter(CallStub::new().with_long_flag("downcase").create())
.is_ok()); .is_ok());
assert!(strutils.is_valid()); assert!(plugin.is_valid());
assert!(strutils.downcase); assert!(plugin.downcase);
} }
#[test] #[test]
fn str_accepts_upcase() { fn str_plugin_accepts_upcase() {
let mut strutils = Str::new(); let mut plugin = Str::new();
assert!(strutils assert!(plugin
.begin_filter(CallStub::new().with_long_flag("upcase").create()) .begin_filter(CallStub::new().with_long_flag("upcase").create())
.is_ok()); .is_ok());
assert!(strutils.is_valid()); assert!(plugin.is_valid());
assert!(strutils.upcase); assert!(plugin.upcase);
} }
#[test] #[test]
fn str_accepts_to_int() { fn str_plugin_accepts_to_int() {
let mut strutils = Str::new(); let mut plugin = Str::new();
assert!(strutils assert!(plugin
.begin_filter(CallStub::new().with_long_flag("to-int").create()) .begin_filter(CallStub::new().with_long_flag("to-int").create())
.is_ok()); .is_ok());
assert!(strutils.is_valid()); assert!(plugin.is_valid());
assert!(strutils.int); assert!(plugin.int);
} }
#[test] #[test]
fn str_accepts_only_one_action() { fn str_plugin_accepts_only_one_action() {
let mut strutils = Str::new(); let mut plugin = Str::new();
assert!(strutils assert!(plugin
.begin_filter( .begin_filter(
CallStub::new() CallStub::new()
.with_long_flag("upcase") .with_long_flag("upcase")
@ -321,15 +321,15 @@ mod tests {
.create(), .create(),
) )
.is_err()); .is_err());
assert!(!strutils.is_valid()); assert!(!plugin.is_valid());
assert_eq!(Some("can only apply one".to_string()), strutils.error); assert_eq!(Some("can only apply one".to_string()), plugin.error);
} }
#[test] #[test]
fn str_accepts_field() { fn str_plugin_accepts_field() {
let mut strutils = Str::new(); let mut plugin = Str::new();
assert!(strutils assert!(plugin
.begin_filter( .begin_filter(
CallStub::new() CallStub::new()
.with_parameter("package.description") .with_parameter("package.description")
@ -337,7 +337,7 @@ mod tests {
) )
.is_ok()); .is_ok());
assert_eq!(Some("package.description".to_string()), strutils.field); assert_eq!(Some("package.description".to_string()), plugin.field);
} }
#[test] #[test]
@ -363,9 +363,9 @@ mod tests {
#[test] #[test]
fn str_plugin_applies_upcase() { fn str_plugin_applies_upcase() {
let mut strutils = Str::new(); let mut plugin = Str::new();
assert!(strutils assert!(plugin
.begin_filter( .begin_filter(
CallStub::new() CallStub::new()
.with_long_flag("upcase") .with_long_flag("upcase")
@ -375,7 +375,7 @@ mod tests {
.is_ok()); .is_ok());
let subject = sample_record("name", "jotandrehuda"); let subject = sample_record("name", "jotandrehuda");
let output = strutils.filter(subject).unwrap(); let output = plugin.filter(subject).unwrap();
match output[0].as_ref().unwrap() { match output[0].as_ref().unwrap() {
ReturnSuccess::Value(Spanned { ReturnSuccess::Value(Spanned {
@ -391,9 +391,9 @@ mod tests {
#[test] #[test]
fn str_plugin_applies_downcase() { fn str_plugin_applies_downcase() {
let mut strutils = Str::new(); let mut plugin = Str::new();
assert!(strutils assert!(plugin
.begin_filter( .begin_filter(
CallStub::new() CallStub::new()
.with_long_flag("downcase") .with_long_flag("downcase")
@ -403,7 +403,7 @@ mod tests {
.is_ok()); .is_ok());
let subject = sample_record("name", "JOTANDREHUDA"); let subject = sample_record("name", "JOTANDREHUDA");
let output = strutils.filter(subject).unwrap(); let output = plugin.filter(subject).unwrap();
match output[0].as_ref().unwrap() { match output[0].as_ref().unwrap() {
ReturnSuccess::Value(Spanned { ReturnSuccess::Value(Spanned {
@ -419,9 +419,9 @@ mod tests {
#[test] #[test]
fn str_plugin_applies_to_int() { fn str_plugin_applies_to_int() {
let mut strutils = Str::new(); let mut plugin = Str::new();
assert!(strutils assert!(plugin
.begin_filter( .begin_filter(
CallStub::new() CallStub::new()
.with_long_flag("to-int") .with_long_flag("to-int")
@ -431,7 +431,7 @@ mod tests {
.is_ok()); .is_ok());
let subject = sample_record("Nu_birthday", "10"); let subject = sample_record("Nu_birthday", "10");
let output = strutils.filter(subject).unwrap(); let output = plugin.filter(subject).unwrap();
match output[0].as_ref().unwrap() { match output[0].as_ref().unwrap() {
ReturnSuccess::Value(Spanned { ReturnSuccess::Value(Spanned {