juju 1.0.0

A library to interact with the Juju system. For an example charm see: https://github.com/cholcombe973/gluster-charm
Documentation
///
/// A basic macro to ease creation and management
/// of Hooks
///
#[macro_export]
macro_rules! hook {
    ($hook_name:expr, $fn_name:ident) => {
        $crate::Hook {
            name: $hook_name.to_string(),
            callback: $fn_name,
        }
    };
    ($hook_name:ident $fn_name:ident) => {
        $crate::Hook {
            name: stringify!($hook_name).to_string(),
            callback: $fn_name,
        }
    };
}

#[macro_export]
macro_rules! log {
    ($message:expr) => {{
        log!($message, Debug)
    }};
    ($message:expr, $level:ident) => {{
         $crate::log(
            $message.to_string(),
            Some($crate::LogLevel::$level),
        );
    }}
}

///
/// A Macro to set Juju's status
///
#[macro_export]
macro_rules! status_set {
    ($status_type:ident $message:expr) => {{
        let _ = $crate::status_set(
            $crate::Status {
                status_type: $crate::StatusType::$status_type,
                message: $message.to_string()
            }
        );
    }}
}

#[cfg(test)]
mod tests {
    #[allow(dead_code)]
    mod status_set {
        fn it_compiles_correctly() {
            status_set!(Maintenance "Doing stuff");
        }
    }

    #[allow(dead_code)]
    mod log {
        fn it_logs_default() {
            log!("This is a test");
        }

        fn it_logs_specific_level() {
            log!("test 2", Warn);
        }
    }

    use super::super::Hook;
    fn cb() -> Result<(), String> {
        Ok(())
    }
    #[test]
    fn it_makes_a_hook_correctly() {
        let h1 = hook!(test cb);
        let h2 = Hook {
            name: "test".to_string(),
            callback: cb,
        };
        assert_eq!(h1, h2);
    }

    #[test]
    fn it_makes_a_complex_named_hook_correctly() {
        let h1 = hook!("config-changed", cb);
        let h2 = Hook {
            name: "config-changed".to_string(),
            callback: cb,
        };
        assert_eq!(h1, h2);
    }
}