terraform_zap_ignore_lib/
lib.rs

1#![deny(missing_debug_implementations, missing_docs, warnings)]
2
3//! # terraform-zap-ignore-lib
4//!
5//! Contain all ignore related implementation
6
7extern crate serde;
8#[macro_use]
9extern crate serde_derive;
10
11/// Root structure to hold the ignore method type
12/// Using #[serde(untagged)] at the moment due to issue
13/// <https://github.com/alexcrichton/toml-rs/issues/225>
14#[derive(Serialize, Deserialize, Debug)]
15#[serde(untagged)]
16pub enum Ignore {
17    /// Variant to ignore by exact string match
18    Exact {
19        /// Array of full resource names to ignore
20        exact: Vec<String>,
21    },
22}
23
24#[cfg(test)]
25mod tests {
26    extern crate toml;
27
28    use super::*;
29
30    #[test]
31    fn test_grep_invert_valid_1() {
32        const CONTENT: &str = r#"
33            exact = []
34        "#;
35
36        let _: Ignore = toml::from_str(CONTENT).unwrap();
37    }
38
39    #[test]
40    fn test_grep_invert_valid_2() {
41        const CONTENT: &str = r#"
42            exact = [
43                "hello",
44                "world",
45            ]
46        "#;
47
48        let _: Ignore = toml::from_str(CONTENT).unwrap();
49    }
50
51    #[test]
52    fn test_invalid_1() {
53        const CONTENT: &str = "";
54        let parsed: Result<Ignore, _> = toml::from_str(CONTENT);
55        assert!(parsed.is_err());
56    }
57
58    #[test]
59    fn test_invalid_2() {
60        const CONTENT: &str = "[]";
61        let parsed: Result<Ignore, _> = toml::from_str(CONTENT);
62        assert!(parsed.is_err());
63    }
64
65    #[test]
66    fn test_invalid_3() {
67        const CONTENT: &str = r#"["hello", "world"]"#;
68        let parsed: Result<Ignore, _> = toml::from_str(CONTENT);
69        assert!(parsed.is_err());
70    }
71}