sktlib 0.1.5

the library for the template creator for kubernetes resources
Documentation
pub mod core;
pub mod stringifyer;

#[cfg(test)]
mod tests {
    use crate::core::daemon_set::DaemonSet;
    use crate::core::deployment::Deployment;
    use crate::core::pod::Pod;
    use crate::core::replica_set::ReplicaSet;
    use crate::core::service::Service;
    use crate::core::stateful_set::StatefulSet;
    use crate::core::manifest_creator::ManifestCreator;
    use crate::core::models::Port;
    use crate::stringifyer::build_string;

    #[test]
    fn test_build_string_with_int() {
        let result = build_string(42);
        assert_eq!(result, "42");
    }

    #[test]
    fn test_build_string_with_float() {
        let result = build_string(3.14);
        assert_eq!(result, "3.14");
    }

    #[test]
    fn test_build_string_with_service() {
        let result = build_string(
            Service::new(
                "test".to_string(),
                "testdeployment".to_string(), vec![
                    Port {
                    protocol: "TCP".to_string(),
                    port: 42,
                    target_port: 42,
                }]
            )
        );
        println!("Testing service:\n{}", result);
    }

    #[test]
    fn test_build_string_with_deployment() {
        let result = build_string(
            Deployment::new(
                "testdeployment".to_string(),
                "python:3".to_string()
            )
        );
        println!("Testing deployment:\n{}", result);
    }

    #[test]
    fn test_build_string_with_stateful_set() {
        let result = build_string(
            StatefulSet::new(
                "testdeployment".to_string(),
                "python3".to_string()
            )
        );
        println!("Testing stateful set:\n{}", result);
    }

    #[test]
    fn test_build_string_with_pod() {
        let result = build_string(
            Pod::new(
                "test".to_string(),
                "testdeployment".to_string()
            )
        );
        println!("{}", result);
    }

    #[test]
    fn test_build_string_with_daemon_set() {
        let result = build_string(
            DaemonSet::new(
                "test".to_string(),
                "testdeployment".to_string()
            )
        );
        println!("Testing daemon set:\n{}", result);
    }

    #[test]
    fn test_build_string_with_replica_set() {
        let result = build_string(
            ReplicaSet::new(
                "test".to_string(),
                "testdeployment".to_string()
            )
        );
        println!("Testing replica set:\n{}", result);
    }

    #[test]
    fn test_build_full_deployment() {
        let result = format!(
            "{}\n---\n{}",
            build_string(
                Deployment::new(
                    "testdeployment".to_string(),
                    "python:3".to_string()
                )
            ),
            build_string(
                Service::new(
                    "test".to_string(),
                    "testdeployment".to_string(),
                    vec![
                        Port {
                            protocol: "TCP".to_string(),
                            port: 5000,
                            target_port: 5000,
                        }
                    ]
                )
            )
        );

        println!("Testing full deployment:\n{}", result);
    }

    #[test]
    fn test_manifest_creator() {
        let mc = ManifestCreator::new();
        println!("Testing manifest_creator deployment:\n\n{}", mc.create_deployment("testor",
                                                                                "python:3")
            .unwrap());
        println!("Testing manifest_creator service:\n\n{}", mc.create_service("test-svc", "test",
                                                                              80).unwrap());
    }
}