summaryrefslogtreecommitdiff
path: root/tests/integration/overrides.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/integration/overrides.rs')
-rw-r--r--tests/integration/overrides.rs59
1 files changed, 59 insertions, 0 deletions
diff --git a/tests/integration/overrides.rs b/tests/integration/overrides.rs
new file mode 100644
index 0000000..f34bf9c
--- /dev/null
+++ b/tests/integration/overrides.rs
@@ -0,0 +1,59 @@
+use crate::git_helpers::create_bare_repo;
+use crate::harness::{SiteBuilder, TestServer, test_config_with_site};
+use crate::runtime::{skip_without_git, skip_without_runtime};
+use std::time::Duration;
+
+#[tokio::test]
+async fn complete_override_builds_without_witryna_yaml() {
+ skip_without_git!();
+ skip_without_runtime!();
+
+ let tempdir = tempfile::tempdir().unwrap();
+ let base_dir = tempdir.path().to_path_buf();
+
+ // Create a repo without witryna.yaml
+ let repo_dir = tempdir.path().join("repos");
+ tokio::fs::create_dir_all(&repo_dir).await.unwrap();
+ let repo_url = create_bare_repo(&repo_dir, "main").await;
+
+ // Complete overrides — witryna.yaml not needed
+ let site = SiteBuilder::new("override-site", &repo_url, "test-token")
+ .overrides(
+ "alpine:latest",
+ "mkdir -p out && echo '<h1>override</h1>' > out/index.html",
+ "out",
+ )
+ .build();
+
+ let server = TestServer::start(test_config_with_site(base_dir.clone(), site)).await;
+
+ let resp = TestServer::client()
+ .post(server.url("/override-site"))
+ .header("Authorization", "Bearer test-token")
+ .send()
+ .await
+ .unwrap();
+ assert_eq!(resp.status().as_u16(), 202);
+
+ // Wait for build
+ let builds_dir = base_dir.join("builds/override-site");
+ let max_wait = Duration::from_secs(120);
+ let start = std::time::Instant::now();
+
+ loop {
+ assert!(start.elapsed() <= max_wait, "build timed out");
+ if builds_dir.join("current").is_symlink() {
+ break;
+ }
+ tokio::time::sleep(Duration::from_millis(500)).await;
+ }
+
+ // Verify output
+ let target = tokio::fs::read_link(builds_dir.join("current"))
+ .await
+ .unwrap();
+ let content = tokio::fs::read_to_string(target.join("index.html"))
+ .await
+ .unwrap();
+ assert!(content.contains("<h1>override</h1>"));
+}