From e3a9c70c16a6a7e271ed33a9eb0b91002b2cad61 Mon Sep 17 00:00:00 2001 From: "yk-lab (k.yamada)" Date: Sat, 27 Jun 2026 22:22:54 +0900 Subject: [PATCH] =?UTF-8?q?docs:=20=E3=83=86=E3=82=B9=E3=83=88=E8=A6=8F?= =?UTF-8?q?=E7=B4=84=E3=82=92=20stub-fetch=20unit=20test=20=E3=81=AE?= =?UTF-8?q?=E5=AE=9F=E6=85=8B=E3=81=AB=E5=90=88=E3=82=8F=E3=81=9B=E3=82=8B?= =?UTF-8?q?=EF=BC=88#55=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CLAUDE.md の「Tests cover pure logic only / Network IO は E2E のみ」は実態と 乖離していた(github/checksum は ./fetch を、download は ../src/github を、 proxy は undici を mock した unit test を持つ)。境界 mock 方針と E2E の役割 分担を明記する Test layering に更新。 - CLAUDE.md: Conventions の Tests 項を実態へ更新 - TODO.md: #55 を解決済み(#58)へ移動 Closes #55 Co-Authored-By: Claude Opus 4.8 Claude-Session: https://claude.ai/code/session_01AECzAv2vcdATecuvLjBSa6 --- CLAUDE.md | 2 +- TODO.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index 9d846fd..18b93f4 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -58,7 +58,7 @@ Key design seams to preserve when editing: - **ESM + Node built-ins**: `import * as fs from 'node:fs'`, `target: ES2022`, `module: ESNext`. Strict TS with `noUnusedLocals`/`noUnusedParameters`. - **`FR-N` comments** (e.g. `(FR-5)`) reference numbered functional requirements in `要求仕様書.md`. Keep these traceable when touching the behavior they annotate. -- **Tests cover pure logic only** — `version`, `platform`, `checksum` parsing. Network/IO modules (`github`, `download`, `install`, `main`) are validated end-to-end by `.github/workflows/self-test.yml`, which runs the built action across a Linux/macOS/Windows × `latest`/`3.x`/`3.51.1` matrix and asserts `task --version` matches the resolved output. +- **Test layering** — unit tests (`vitest`) are deterministic and never touch the real network. Pure logic (`version`, `platform`, `checksum` parsing, `inputs`, `url-guard`) is tested directly; HTTP/IO modules are tested by **mocking the boundary**, not by hitting the network — `github`/`checksum` mock `./fetch`, `download` mocks `@actions/tool-cache` + `../src/github` (orchestration only), `proxy` mocks `undici`. The *real* IO path (live downloads, checksum verification, proxy egress) is validated end-to-end by `.github/workflows/self-test.yml`, which runs the built action across a Linux/macOS/Windows × `latest`/`3.x`/`3.51.1` matrix plus `skip-checksum` and behind-a-proxy jobs, asserting `task --version` matches the resolved output. ## Reference docs diff --git a/TODO.md b/TODO.md index f4ee026..112892c 100644 --- a/TODO.md +++ b/TODO.md @@ -53,7 +53,6 @@ | [#41](https://github.com/yk-lab/setup-task/issues/41) | `[test]` platform.test.ts を §9 全 os/arch 組合せに拡張 | `P3: low` | `test` | | [#44](https://github.com/yk-lab/setup-task/issues/44) | `[enhancement]` フォールバックソースをサポート(FR-11) | `P3: low` | `enhancement` | | [#45](https://github.com/yk-lab/setup-task/issues/45) | `[chore]` Biome 導入を評価 | `P3: low` | `chore` | -| [#55](https://github.com/yk-lab/setup-task/issues/55) | `[documentation]` テスト規約(CLAUDE.md)を stub-fetch unit test の実態に合わせる | `P3: low` | `documentation` | | | [#56](https://github.com/yk-lab/setup-task/issues/56) | `[security]` 取得ボディにサイズ上限/タイムアウトを設ける | `P3: low` | `security` | | ### 未 Issue 化 @@ -80,3 +79,4 @@ v1.0.0 実装中に作成・解決済みの Issue(参考)。 | [#43](https://github.com/yk-lab/setup-task/issues/43) | `[chore]` checksum 改ざんテストの重複ファイルを統合 | #52 | | [#42](https://github.com/yk-lab/setup-task/issues/42) | `[security]` ダウンロード先ホスト/リダイレクト先を検証(NFR-1) | #53 | | [#54](https://github.com/yk-lab/setup-task/issues/54) | `[enhancement]` HTTP(S) proxy 環境で全 fetch を proxy 経由にする | #57 | +| [#55](https://github.com/yk-lab/setup-task/issues/55) | `[documentation]` テスト規約(CLAUDE.md)を stub-fetch unit test の実態に合わせる | #58 |