summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/config.rs6
-rw-r--r--src/http/mod.rs6
-rw-r--r--src/http/render.rs3
-rw-r--r--src/http/routes/mod.rs6
-rw-r--r--src/sandbox/kata.rs35
5 files changed, 50 insertions, 6 deletions
diff --git a/src/config.rs b/src/config.rs
index cd43b97..bb60cc7 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -133,6 +133,11 @@ pub struct Config {
pub dispatch_tick_secs: u64,
}
+/// Test-tier only, and already half-gated: the `hooks` field that holds one and
+/// the `Default` line that fills it are both behind `test-support`, so without
+/// the gate below this type compiles into a release binary that can never
+/// construct, read, or deserialize it.
+#[cfg(feature = "test-support")]
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(default)]
pub struct TestHooks {
@@ -145,6 +150,7 @@ pub struct TestHooks {
pub shim_plant_link: Option<String>,
}
+#[cfg(feature = "test-support")]
impl TestHooks {
pub fn is_empty(&self) -> bool {
self.path_prepend.is_none()
diff --git a/src/http/mod.rs b/src/http/mod.rs
index 5c34466..a77869e 100644
--- a/src/http/mod.rs
+++ b/src/http/mod.rs
@@ -48,7 +48,8 @@ pub(crate) struct Res {
}
impl Res {
- pub fn html(status: u16, body: String) -> Self {
+ /// `pub(crate)`, not `pub`: the census counted it as test-only because the word appears in `tests/http.rs`, but only inside a string — a route path, a content type, the word "redirect" in an assertion message. Nothing in the test tier calls it.
+ pub(crate) fn html(status: u16, body: String) -> Self {
Self { status, content_type: "text/html; charset=utf-8".into(), body: body.into_bytes(), headers: Vec::new(), stream: None, stream_len: None }
}
pub fn text(status: u16, body: String) -> Self {
@@ -64,7 +65,8 @@ impl Res {
stream_len: known_len,
}
}
- pub fn redirect(location: &str) -> Self {
+ /// `pub(crate)`, not `pub`: the census counted it as test-only because the word appears in `tests/http.rs`, but only inside a string — a route path, a content type, the word "redirect" in an assertion message. Nothing in the test tier calls it.
+ pub(crate) fn redirect(location: &str) -> Self {
Self {
status: 303,
content_type: "text/plain".into(),
diff --git a/src/http/render.rs b/src/http/render.rs
index fdf5676..470125d 100644
--- a/src/http/render.rs
+++ b/src/http/render.rs
@@ -179,7 +179,8 @@ pub(crate) struct SubRow {
#[derive(Template)]
#[template(path = "attention.html")]
-pub struct Attention {
+/// `pub(crate)`, not `pub`: the census counted it as test-only because the word appears in `tests/http.rs`, but only inside a string — a route path, a content type, the word "redirect" in an assertion message. Nothing in the test tier calls it.
+pub(crate) struct Attention {
pub page: Page,
pub empty: bool,
pub notices: Vec<NoticeRow>,
diff --git a/src/http/routes/mod.rs b/src/http/routes/mod.rs
index 7495524..1ef7fde 100644
--- a/src/http/routes/mod.rs
+++ b/src/http/routes/mod.rs
@@ -33,7 +33,8 @@ pub(crate) fn login_form(state: &State, req: &Req) -> Res {
page_to_res(Login { page, error: String::new() }, 200)
}
-pub fn logout(req: &Req) -> Res {
+/// `pub(crate)`, not `pub`: the census counted it as test-only because the word appears in `tests/http.rs`, but only inside a string — a route path, a content type, the word "redirect" in an assertion message. Nothing in the test tier calls it.
+pub(crate) fn logout(req: &Req) -> Res {
if let Some(sid) = req.cookie("sid") {
auth::drop_session(&sid);
}
@@ -62,7 +63,8 @@ pub fn login(state: &State, req: &Req) -> Res {
}
}
-pub fn route(state: &State, req: &Req, seg: &[&str]) -> Res {
+/// `pub(crate)`, not `pub`: the census counted it as test-only because the word appears in `tests/http.rs`, but only inside a string — a route path, a content type, the word "redirect" in an assertion message. Nothing in the test tier calls it.
+pub(crate) fn route(state: &State, req: &Req, seg: &[&str]) -> Res {
match (req.method.as_str(), seg) {
("GET", []) => dashboard(state, req),
("GET", ["reviews"]) => reviews(state, req),
diff --git a/src/sandbox/kata.rs b/src/sandbox/kata.rs
index 66f7cba..26e9acc 100644
--- a/src/sandbox/kata.rs
+++ b/src/sandbox/kata.rs
@@ -83,7 +83,7 @@ impl K8sSandboxProvisioner {
}
}
-pub struct K8sSandboxProvisioner {
+pub(crate) struct K8sSandboxProvisioner {
pub api: String,
pub bearer: String,
pub namespace: String,
@@ -447,4 +447,37 @@ mod tests {
assert!(started.elapsed() >= Duration::from_millis(900), "acquire gave up before the TTL");
assert!(err.to_string().contains("never dialed in"), "{err}");
}
+
+ // ------------------------------------------------------------------
+ // Moved verbatim from tests/kata.rs. It is an opt-in live tier, not a
+ // fixture test: it records its own absence when there is no /dev/kvm or no
+ // AUR_KATA_API, exactly as the vercmp live tier does. It constructs the
+ // provisioner field by field, which is the only reason that struct was
+ // nameable from outside; with the test here, it no longer needs to be.
+ // ------------------------------------------------------------------
+
+ #[test]
+ fn the_live_kata_tier_is_recorded_not_silently_absent() {
+ if !std::path::Path::new("/dev/kvm").exists() {
+ println!("note: no /dev/kvm on this host; the live kata tier is skipped, not passed");
+ return;
+ }
+ let Ok(api) = std::env::var("AUR_KATA_API") else {
+ println!("note: /dev/kvm present but AUR_KATA_API unset; live kata tier still skipped");
+ return;
+ };
+ let cfg = Config::default();
+ let prov = Arc::new(K8sSandboxProvisioner {
+ api,
+ bearer: std::env::var("AUR_KATA_TOKEN").unwrap_or_default(),
+ namespace: std::env::var("AUR_KATA_NS").unwrap_or_else(|_| "default".into()),
+ });
+ let backend = KataBackend::bind(&cfg, "0.0.0.0:9443", &std::env::var("AUR_AGENT_TOKEN").unwrap(), prov).unwrap();
+ let sbx = backend
+ .acquire(&SandboxSpec::new("extra-x86_64", "live", Duration::from_secs(300)))
+ .expect("live kata sandbox should lease");
+ let out = sbx.run(&crate::sandbox::Cmd::new(["/bin/echo", "kata"]), &mut |_| {}).unwrap();
+ assert!(out.success() && String::from_utf8_lossy(&out.stdout).contains("kata"));
+ sbx.destroy().unwrap();
+ }
}