Introduce test-only fixture structs in pikaci_store.rs
Intent: Create reusable, type-safe structs (`TestPikaciRunFixture` and `TestPikaciJobFixture`) that represent the data needed to write a complete CI run fixture to disk, replacing scattered raw JSON and manual file operations across tests.
Affected files: crates/pika-news/src/pikaci_store.rs
@@ -3,6 +3,11 @@ use std::path::{Path, PathBuf};
use anyhow::{anyhow, Result};
use pikaci::{load_logs, load_run_bundle, load_run_record, LogKind, Logs, RunBundle, RunRecord};
+#[cfg(test)]
+use pikaci::{JobRecord, PreparedOutputsRecord, RemoteLinuxVmExecutionRecord, RunStatus};
+#[cfg(test)]
+use std::fs;
@@ -10,6 +15,80 @@ pub struct PikaciRunStore {
state_root: PathBuf,
}
+#[cfg(test)]
+#[derive(Clone, Debug)]
+pub struct TestPikaciJobFixture {
@@ -10,6 +15,80 @@
+#[cfg(test)]
+#[derive(Clone, Debug)]
+pub struct TestPikaciRunFixture {
@@ -10,6 +15,80 @@
+impl TestPikaciJobFixture {
+ pub fn passed_remote_linux(job_id: &str, description: &str) -> Self {
@@ -10,6 +15,80 @@
+impl TestPikaciRunFixture {
+ pub fn passed(run_id: &str, target_id: Option<&str>, target_description: Option<&str>) -> Self {
Two new #[cfg(test)] structs are added to pikaci_store.rs:
-
TestPikaciJobFixtureholds all fields needed for a single CI job fixture: id, description, status, executor type, log content, timing, exit code, and optionalRemoteLinuxVmExecutionRecord. A convenience constructorpassed_remote_linux()creates a fully-populated passing job with sensible defaults. -
TestPikaciRunFixtureholds run-level fields (run_id, status, target info, timestamps) plus aVec<TestPikaciJobFixture>for jobs and an optionalPreparedOutputsRecord. Thepassed()constructor creates a minimal passing run.
Both structs are gated behind #[cfg(test)] so they have zero impact on production builds. The conditional imports pull in JobRecord, PreparedOutputsRecord, RemoteLinuxVmExecutionRecord, RunStatus, and std::fs only during testing.