diff --git a/dsc/src/args.rs b/dsc/src/args.rs index 94ac07ee..9cc318a3 100644 --- a/dsc/src/args.rs +++ b/dsc/src/args.rs @@ -100,8 +100,10 @@ pub enum ConfigSubCommand { path: Option, #[clap(short = 'f', long, help = "The output format to use")] format: Option, + // Used by Assertion resource to return `test` result as a `get` result #[clap(long, hide = true)] as_get: bool, + // Used by Assertion resource to return `test` result as a configuration `test` result #[clap(long, hide = true)] as_config: bool, }, diff --git a/dsc_lib/src/dscresources/dscresource.rs b/dsc_lib/src/dscresources/dscresource.rs index f82f9bf3..7c62bda1 100644 --- a/dsc_lib/src/dscresources/dscresource.rs +++ b/dsc_lib/src/dscresources/dscresource.rs @@ -478,63 +478,71 @@ fn array_contains(array: &Vec, find: &Value) -> bool { #[test] fn same_array() { use serde_json::json; - let array_one = vec![json!("a"), json!(1), json!(r#"{"a":"b"}"#), json!(null)]; - let array_two = vec![json!("a"), json!(1), json!(r#"{"a":"b"}"#), json!(null)]; + let array_one = vec![json!("a"), json!(1), json!({"a":"b"}), json!(null)]; + let array_two = vec![json!("a"), json!(1), json!({"a":"b"}), json!(null)]; assert_eq!(is_same_array(&array_one, &array_two), true); } #[test] fn same_array_out_of_order() { use serde_json::json; - let array_one = vec![json!("a"), json!(true), json!(r#"{"a":"b"}"#)]; - let array_two = vec![json!(r#"{"a":"b"}"#), json!("a"), json!(true)]; + let array_one = vec![json!("a"), json!(true), json!({"a":"b"})]; + let array_two = vec![json!({"a":"b"}), json!("a"), json!(true)]; assert_eq!(is_same_array(&array_one, &array_two), true); } #[test] fn different_array() { use serde_json::json; - let array_one = vec![json!("a"), json!(1), json!(r#"{"a":"b"}"#)]; - let array_two = vec![json!(r#"{"a":"b"}"#), json!("a"), json!(2)]; + let array_one = vec![json!("a"), json!(1), json!({"a":"b"})]; + let array_two = vec![json!({"a":"b"}), json!("a"), json!(2)]; assert_eq!(is_same_array(&array_one, &array_two), false); } #[test] fn different_array_sizes() { use serde_json::json; - let array_one = vec![json!("a"), json!(1), json!(r#"{"a":"b"}"#)]; - let array_two = vec![json!(r#"{"a":"b"}"#), json!("a")]; + let array_one = vec![json!("a"), json!(1), json!({"a":"b"})]; + let array_two = vec![json!({"a":"b"}), json!("a")]; assert_eq!(is_same_array(&array_one, &array_two), false); } #[test] -fn array_with_multiple_objects_with_superset() { +fn array_with_multiple_objects_with_actual_superset() { use serde_json::json; - let array_one = vec![json!("a"), json!(1), json!(r#"{"a":"b"}"#), json!(r#"{"c":"d"}"#)]; - let array_two = vec![json!("a"), json!(1), json!(r#"{"a":"b", "c":"d"}"#), json!(r#"{"c":"d"}"#)]; + let array_one = vec![json!("a"), json!(1), json!({"a":"b"}), json!({"c":"d"})]; + let array_two = vec![json!("a"), json!(1), json!({"c":"d", "a":"b"}), json!({"c":"d"})]; + assert_eq!(is_same_array(&array_one, &array_two), true); +} + +#[test] +fn array_with_multiple_objects_with_expected_superset() { + use serde_json::json; + let array_one = vec![json!("a"), json!(1), json!({"a":"b", "c":"d"}), json!({"c":"d"})]; + let array_two = vec![json!("a"), json!(1), json!({"a":"b"}), json!({"c":"d"})]; assert_eq!(is_same_array(&array_one, &array_two), false); } #[test] fn array_with_duplicates_out_of_order() { use serde_json::json; - let array_one = vec![json!("a"), json!(1), json!(r#"{"a":"b"}"#), json!(r#"{"a":"b"}"#)]; - let array_two = vec![json!(r#"{"a":"b"}"#), json!("a"), json!(1), json!(r#"{"a":"b"}"#)]; + let array_one = vec![json!("a"), json!(1), json!({"a":"b"}), json!({"a":"b"})]; + let array_two = vec![json!({"a":"b"}), json!("a"), json!(1), json!({"a":"b"})]; assert_eq!(is_same_array(&array_one, &array_two), true); } #[test] fn same_array_with_nested_array() { use serde_json::json; - let array_one = vec![json!("a"), json!(1), json!(r#"{"a":"b"}"#), json!(vec![json!("a"), json!(1)])]; - let array_two = vec![json!("a"), json!(1), json!(r#"{"a":"b"}"#), json!(vec![json!("a"), json!(1)])]; + let array_one = vec![json!("a"), json!(1), json!({"a":"b"}), json!(vec![json!("a"), json!(1)])]; + let array_two = vec![json!("a"), json!(1), json!({"a":"b"}), json!(vec![json!("a"), json!(1)])]; assert_eq!(is_same_array(&array_one, &array_two), true); } #[test] fn different_array_with_nested_array() { use serde_json::json; - let array_one = vec![json!("a"), json!(1), json!(r#"{"a":"b"}"#), json!(vec![json!("a"), json!(1)])]; - let array_two = vec![json!("a"), json!(1), json!(r#"{"a":"b"}"#), json!(vec![json!("a"), json!(2)])]; + let array_one = vec![json!("a"), json!(1), json!({"a":"b"}), json!(vec![json!("a"), json!(1)])]; + let array_two = vec![json!("a"), json!(1), json!({"a":"b"}), json!(vec![json!("a"), json!(2)])]; assert_eq!(is_same_array(&array_one, &array_two), false); }