diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 9e20da7..54d6306 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -22,8 +22,21 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 + - name: Install Rust + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + target: x86_64-unknown-linux-gnu + override: true + + - name: Create k8s Kind Cluster + uses: helm/kind-action@v1 + + - name: Create secret + run: | + ssh-keygen -t rsa -b 4096 -f /tmp/id_rsa <<< y + kubectl create ns myns + kubectl create secret generic ssh-key -n myns --from-file=ssh-privatekey=/tmp/id_rsa - name: run tests - run: docker run $(docker build -q -f Dockerfile.test .) cargo test + run: cargo test diff --git a/Dockerfile.test b/Dockerfile.test deleted file mode 100644 index 81cd983..0000000 --- a/Dockerfile.test +++ /dev/null @@ -1,16 +0,0 @@ -FROM rust:1.83.0-slim - -COPY . . - -RUN apt-get update && apt-get install -y \ - perl \ - perl-modules \ - pkg-config \ - libssl-dev \ - make \ - build-essential \ - git \ - && rm -rf /var/lib/apt/lists/* - -WORKDIR /app -COPY . . diff --git a/src/configuration/configuration.rs b/src/configuration/configuration.rs index bce6460..65deb97 100644 --- a/src/configuration/configuration.rs +++ b/src/configuration/configuration.rs @@ -179,9 +179,6 @@ async fn get_notifications_endpoint(name: &str, namespace: &str) -> Option Result<(), String> { info!("Processing: {}/{}", &entry.namespace, &entry.name); - if !entry.config.enabled { - warn!("Config is disabled for deployment: {}", &entry.name); - } let endpoint = get_notifications_endpoint( &entry.config.notifications_secret_name.unwrap_or_default(), @@ -319,6 +316,8 @@ pub async fn reconcile(State(store): State) -> Json> { .iter() .filter_map(|d| deployment_to_entry(d)) .collect(); + + println!("{:?}", data); let mut handles: Vec<_> = vec![]; for entry in &data { diff --git a/tests/configuration_tests.rs b/tests/configuration_tests.rs index 8a0818c..fd07f9e 100644 --- a/tests/configuration_tests.rs +++ b/tests/configuration_tests.rs @@ -302,10 +302,15 @@ mod tests { let entries = response.0; assert_eq!(entries.len(), 1); - assert_eq!(entries[0].name, "test-app"); - assert_eq!(entries[0].namespace, "default"); - assert_eq!(entries[0].container, "my-container"); - assert_eq!(entries[0].version, "1.0.0"); + let entry1 = entries + .iter() + .find(|e| { + e.to_string() + == "Deployment: test-app is up to date, proceeding to next deployment..." + }) + .unwrap(); + + assert!(entry1.to_string().contains("test-app")); } #[tokio::test] @@ -404,45 +409,34 @@ mod tests { // Call reconcile endpoint let response = reconcile(State(reader)).await; let entries = response.0; + println!("{:?}", entries); // Verify the results - // Should only include valid deployments (enabled and disabled) - assert_eq!(entries.len(), 2); + // Should only include valid deployments and enabled + assert_eq!(entries.len(), 1); // Check first deployment (enabled) - let entry1 = entries.iter().find(|e| e.name == "test-app1").unwrap(); - assert_eq!(entry1.namespace, "default"); - assert_eq!(entry1.container, "container1"); - assert_eq!(entry1.version, "1.0.0"); - assert!(entry1.config.enabled); - assert_eq!(entry1.config.app_repository, "https://github.com/org/app1"); - assert_eq!( - entry1.config.notifications_secret_name, - Some(String::from("test-app1-notifications")) - ); - assert_eq!( - entry1.config.notifications_secret_namespace, - Some(String::from("default")) - ); - - // Check second deployment (disabled) - let entry2 = entries.iter().find(|e| e.name == "test-app2").unwrap(); - assert_eq!(entry2.namespace, "default"); - assert_eq!(entry2.container, "container2"); - assert_eq!(entry2.version, "2.0.0"); - assert!(!entry2.config.enabled); - assert_eq!(entry2.config.app_repository, "https://github.com/org/app2"); - assert_eq!( - entry2.config.notifications_secret_name, - Some(String::from("test-app1-notifications")) - ); - assert_eq!( - entry2.config.notifications_secret_namespace, - Some(String::from("default")) - ); + let entry1 = entries + .iter() + .find(|e| { + e.to_string() + == "Deployment: test-app1 is up to date, proceeding to next deployment..." + }) + .unwrap(); + + assert!(entry1.to_string().contains("test-app1")); + + // Check that the second deployment (disabled) is not present + assert!(entries + .iter() + .find(|e| { e.to_string() == "test-app2" }) + .is_none()); // Verify the invalid deployment is not included - assert!(entries.iter().find(|e| e.name == "test-app3").is_none()); + assert!(entries + .iter() + .find(|e| e.to_string() == "test-app3") + .is_none()); } #[tokio::test]