release: v0.2.5
CI / fmt (rustfmt --check) (push) Waiting to run
CI / clippy (ubuntu-latest) (push) Waiting to run
CI / clippy (windows-latest) (push) Waiting to run
CI / test (ubuntu-latest) (push) Waiting to run
CI / test (windows-latest) (push) Waiting to run
CI / build release (ubuntu-latest) (push) Waiting to run
CI / build release (windows-latest) (push) Waiting to run
CI / runtime smoke (ubuntu x64, xvfb) (push) Waiting to run
CI / runtime smoke (macos arm64, probe) (push) Skipped
CI / update-e2e (windows x64) (push) Waiting to run
GPU evidence / GPU 判据自测(不需 GPU;跳过 ≠ 已验证) (push) Waiting to run
GPU evidence / GPU 证据 — 探测可用产物与硬件适配器 (push) Waiting to run
Guards / core 零 UI 守门 (push) Waiting to run
Guards / presenter 零 UI 守门 (push) Waiting to run
Guards / design 零第三方依赖守门 (push) Waiting to run
Guards / unsafe 落点守门(集合必须恰好等于期望) (push) Waiting to run
Guards / 文件行数 ≤400 守门 (push) Waiting to run
Guards / 依赖许可与来源(cargo-deny) (push) Waiting to run
Release guard / 发布标记语义守门(push tag → 稳定版) (push) Waiting to run
Signing status(播报,不是门禁) / 判据自测(三行/退出码/变异重放/接线) (push) Waiting to run
Signing status(播报,不是门禁) / 签名就绪度(播报) (push) Waiting to run
Release / 选槽位(默认四个:Windows 两档 + Linux 两档) (push) Waiting to run
CI / fmt (rustfmt --check) (push) Waiting to run
CI / clippy (ubuntu-latest) (push) Waiting to run
CI / clippy (windows-latest) (push) Waiting to run
CI / test (ubuntu-latest) (push) Waiting to run
CI / test (windows-latest) (push) Waiting to run
CI / build release (ubuntu-latest) (push) Waiting to run
CI / build release (windows-latest) (push) Waiting to run
CI / runtime smoke (ubuntu x64, xvfb) (push) Waiting to run
CI / runtime smoke (macos arm64, probe) (push) Skipped
CI / update-e2e (windows x64) (push) Waiting to run
GPU evidence / GPU 判据自测(不需 GPU;跳过 ≠ 已验证) (push) Waiting to run
GPU evidence / GPU 证据 — 探测可用产物与硬件适配器 (push) Waiting to run
Guards / core 零 UI 守门 (push) Waiting to run
Guards / presenter 零 UI 守门 (push) Waiting to run
Guards / design 零第三方依赖守门 (push) Waiting to run
Guards / unsafe 落点守门(集合必须恰好等于期望) (push) Waiting to run
Guards / 文件行数 ≤400 守门 (push) Waiting to run
Guards / 依赖许可与来源(cargo-deny) (push) Waiting to run
Release guard / 发布标记语义守门(push tag → 稳定版) (push) Waiting to run
Signing status(播报,不是门禁) / 判据自测(三行/退出码/变异重放/接线) (push) Waiting to run
Signing status(播报,不是门禁) / 签名就绪度(播报) (push) Waiting to run
Release / 选槽位(默认四个:Windows 两档 + Linux 两档) (push) Waiting to run
This commit is contained in:
commit
0522a41a52
1587 files changed
+323674
No files matched your search
@@ -0,0 +1,67 @@
|
||||
//! `SourceFailed.kind` 的另一半(M197 复审 P2-2):**404 是「该源没有这个文件」**,不是「源坏了」。
|
||||
//!
|
||||
//! 两档在引擎里的后果不同:`NotFound` 走 `record_missing`(不冷却源),`ServerError` 走
|
||||
//! `record_failure`。院校镜像只留最新补丁,请求旧补丁必然 404——判成「源坏了」会把唯一可用镜像
|
||||
//! 冷却掉(M33/M34 实测)。
|
||||
//!
|
||||
//! 变异证明:把 `engine.rs` / `bytes.rs` 的 `kind: err.kind` 改成常量 `Network` ⇒ 本条与
|
||||
//! `reports_progress_events_and_errors_when_all_sources_fail` 一起红。
|
||||
//!
|
||||
//! 拆成子模块:`engine_mock_test.rs` 加了这条之后 407 行,越过 400 行硬线(`guards.yml` 的
|
||||
//! `file-size`),于是把整条用例搬出来。
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
use unlucky_core::download::cache::ContentCache;
|
||||
use unlucky_core::download::engine::DownloadEngine;
|
||||
use unlucky_core::download::error::DownloadErrorKind;
|
||||
use unlucky_core::download::health::HealthRegistry;
|
||||
use unlucky_core::download::mirrors::MirrorTable;
|
||||
use unlucky_core::download::progress::{ProgressEmitter, ProgressEvent};
|
||||
use unlucky_core::download::types::{DownloadRequest, ResourceKind};
|
||||
|
||||
use super::support::{temp_dir, MockResponse, MockServer};
|
||||
use super::{direct_region, fast_config};
|
||||
|
||||
#[tokio::test]
|
||||
async fn a_404_is_classified_as_not_found() {
|
||||
let server = MockServer::start(vec![
|
||||
MockResponse::status(404),
|
||||
MockResponse::status(404),
|
||||
MockResponse::status(404),
|
||||
MockResponse::status(404),
|
||||
])
|
||||
.await;
|
||||
let url = server.url("/gone.jar");
|
||||
let dir = temp_dir("engine-404");
|
||||
let (emitter, mut events) = ProgressEmitter::channel();
|
||||
let engine = DownloadEngine::new(
|
||||
fast_config(1),
|
||||
Arc::new(MirrorTable::builtin()),
|
||||
Arc::new(direct_region()),
|
||||
Arc::new(HealthRegistry::in_memory()),
|
||||
Arc::new(ContentCache::open(dir.join("cache"))),
|
||||
)
|
||||
.with_progress(emitter);
|
||||
engine
|
||||
.download(DownloadRequest::new(
|
||||
ResourceKind::Library,
|
||||
url.as_str(),
|
||||
dir.join("gone.jar"),
|
||||
))
|
||||
.await
|
||||
.expect_err("只有 404 的源必须失败");
|
||||
|
||||
let mut seen: Vec<DownloadErrorKind> = Vec::new();
|
||||
while let Ok(event) = events.try_recv() {
|
||||
if let ProgressEvent::SourceFailed { kind, .. } = event {
|
||||
seen.push(kind);
|
||||
}
|
||||
}
|
||||
assert!(!seen.is_empty(), "至少要有一条 SourceFailed");
|
||||
assert!(
|
||||
seen.iter().all(|kind| *kind == DownloadErrorKind::NotFound),
|
||||
"404 必须分类成 NotFound,实际:{seen:?}"
|
||||
);
|
||||
server.stop();
|
||||
}
|
||||
Reference in new issue
Block a user