Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions app/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ edition = "2024"
rust-version = "1.99"
license = "Apache-2.0"
publish = false
# The integration tests are one binary (tests/all.rs), linked once: see that file.
autotests = false

# Laravel Rust's convention: the library is `app`.
[lib]
Expand All @@ -18,6 +20,26 @@ name = "app"
name = "visualci-app"
path = "src/main.rs"

[[test]]
name = "app"
path = "tests/all.rs"

[[test]]
name = "live"
path = "tests/live.rs"

[[test]]
name = "live_limits"
path = "tests/live_limits.rs"

[[test]]
name = "mcp_hosts"
path = "tests/mcp_hosts.rs"

[[test]]
name = "proxies"
path = "tests/proxies.rs"

[dependencies]
# Pinned exactly: each 0.x minor of Laravel Rust may break, and upgrades are deliberate.
laravel-rust = { version = "=0.1.4", features = ["database-postgres", "minijinja"] }
Expand Down
90 changes: 90 additions & 0 deletions app/tests/all.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
//! Every integration test of the app, in one test binary.
//!
//! Each file in `tests/` used to be its own binary: 53 links of the whole app on every run, then Cargo ran them one
//! after another. Here they're modules of one crate, linked once, and their tests all run in parallel, which Laravel
//! Rust's tests support (each gets its own application and, with `refresh_database`, its own database).
//!
//! A file whose tests need a process of their own (a per-process counter or service built from the first test's
//! settings, the live-updates listener started on the first caller's runtime) stays its own binary, as a `[[test]]` in
//! Cargo.toml: live, live_limits, mcp_hosts and proxies. The MCP services here take their allowed hosts from the first
//! test that reaches them, so a test that needs other hosts (`mcp.visualci.test`, `VISUALCI_MCP_HOSTS`) goes there too.
//!
//! A new test file goes in the list below or in Cargo.toml: `every_test_file_is_listed` fails unless it's in exactly
//! one, since Cargo no longer finds test files by itself (`autotests = false`).
//! `cargo test -p visualci-app <file>::` runs one file's tests.

mod golden;
mod oauth_client;

mod abuse;
mod api_builds;
mod app_shell;
mod auth;
mod baselines;
mod billing;
mod branches;
mod credit_overrides;
mod credits;
mod demo;
mod device;
mod downloads;
mod emails;
mod fingerprints;
mod forge_events;
mod forge_reports;
mod forge_sync;
mod gallery;
mod github_calls;
mod groups;
mod hosts;
mod installations;
mod invitations;
mod link;
mod live_streams;
mod load;
mod masks;
mod mcp;
mod mcp_admin;
mod mcp_uploads;
mod me;
mod memberships;
mod oauth;
mod org_settings;
mod organizations;
mod orgs;
mod processing;
mod processing_lock;
mod renderer;
mod reruns;
mod retention;
mod scaffold;
mod screenshots_seed;
mod setup;
mod sign_in;
mod staff;
mod staff_commands;
mod storage;
mod storage_blobs;
mod sweep;
mod tokens;
mod ui;
mod webhooks;

#[test]
fn every_test_file_is_listed() {
let dir = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("tests");
let listed = include_str!("all.rs");
let own_binaries = include_str!("../Cargo.toml");
let mut wrong = Vec::new();
for entry in std::fs::read_dir(&dir).unwrap() {
let path = entry.unwrap().path();
let is_module = path.extension().is_some_and(|e| e == "rs") || path.join("mod.rs").is_file();
let Some(module) = path.file_stem().and_then(|s| s.to_str()).filter(|_| is_module) else { continue };
let in_all = listed.lines().any(|line| line == format!("mod {module};"));
let own_binary = own_binaries.lines().any(|line| line == format!("path = \"tests/{module}.rs\""));
if module != "all" && in_all == own_binary {
wrong.push(module.to_owned());
}
}
assert!(wrong.is_empty(), "list each of these once, in tests/all.rs or as a [[test]] in Cargo.toml: {wrong:?}");
}
2 changes: 1 addition & 1 deletion app/tests/api_builds.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! The CI API's builds: today's answers (tests/golden/api) for the same requests.

mod golden;
use crate::golden;

use app::testing::fixtures;
use laravel::db;
Expand Down
2 changes: 1 addition & 1 deletion app/tests/live_streams.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//! arrives inside a test's rolled-back transaction, so what a stream sends after its snapshot is tested on its own
//! channel.

mod oauth_client;
use crate::oauth_client;

use std::time::Duration;

Expand Down
2 changes: 1 addition & 1 deletion app/tests/mcp.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! The public MCP server's tools: today's answers (tests/golden/mcp) for the same calls. `whoami`'s `via` and
//! `list_builds`' compact lines are deliberate changes from today's answers.

mod golden;
use crate::golden;

use std::collections::HashMap;
use std::sync::Mutex;
Expand Down
4 changes: 2 additions & 2 deletions app/tests/mcp_admin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
//! admin token gets in, the regular `/mcp` never shows admin tools, writes need a reason, and every call is audited.
//! Each tool's answer is checked against tests/golden/mcp_admin.

mod golden;
mod oauth_client;
use crate::golden;
use crate::oauth_client;

use std::collections::HashMap;
use std::sync::Mutex;
Expand Down
Loading