test: fetchJson の content-type ガードと createReleaseApi を検証#26
Conversation
要求仕様書 §10.1 / 企画 §1.1-3。既存の fetchText テストに加え: - fetchJson: 正常 JSON / HTML レート制限ページ→retryable Error(repo-token 案内)/ 404→PermanentError / 503→Error - createReleaseApi.getLatestVersion: tag_name をそのまま返す - createReleaseApi.listStableVersions: draft/prerelease 除外 + ページング追従(page=2 取得→部分ページで停止)+ 空ページ停止 fetch を URL/呼び出し回数で分岐スタブし、ページングを実検証。 Closes #3 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
📝 WalkthroughSummary by CodeRabbit
Walkthrough
Changesgithub.ts テストカバレッジ追加
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
tests/github.test.ts (1)
21-142:⚠️ Potential issue | 🟠 Major | 🏗️ Heavy lift
github(network/IO)へのユニットテスト追加がテスト方針に反しています。Line 21〜Line 142 で
fetchJson/fetchText/createReleaseApiをユニットテストしていますが、githubは network/IO モジュールです。これらは.github/workflows/self-test.ymlの E2E 検証へ移し、tests/**/*.test.ts側は純粋ロジックモジュールに限定してください。
As per coding guidelines,tests/**/*.test.{ts,tsx}では「Write tests only for pure logic modules (version,platform,checksumparsing); validate network/IO modules (github,download,install,main) end-to-end via.github/workflows/self-test.yml」を満たす必要があります。🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/github.test.ts` around lines 21 - 142, Remove the three describe blocks testing fetchJson, fetchText, and createReleaseApi (lines 21-142) from the unit test file, as these functions are part of the network/IO github module and should not be validated through unit tests. Instead, these network/IO validations should be moved to end-to-end tests in the .github/workflows/self-test.yml workflow file, keeping the tests/**/*.test.ts file limited to pure logic modules like version, platform, and checksum parsing.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@tests/github.test.ts`:
- Around line 21-142: Remove the three describe blocks testing fetchJson,
fetchText, and createReleaseApi (lines 21-142) from the unit test file, as these
functions are part of the network/IO github module and should not be validated
through unit tests. Instead, these network/IO validations should be moved to
end-to-end tests in the .github/workflows/self-test.yml workflow file, keeping
the tests/**/*.test.ts file limited to pure logic modules like version,
platform, and checksum parsing.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: bcd309e2-1e73-4d67-84ac-2546b1f167a2
📒 Files selected for processing (1)
tests/github.test.ts
概要
src/github.tsのfetchJson(content-type ガード)とcreateReleaseApiのユニットテストを追加します(要求仕様書 §10.1 / 企画 §1.1-3)。HTML "Unicorn" ページを失敗扱いにする本アクションの存在意義が未検証でした。テストケース(github.test.ts: 3 → 10)
content-type&repo-tokenを含む)/ 404 →PermanentError/ 503 → retryable Errortag_nameをそのまま返すfetchを URL・呼び出し回数で分岐スタブし、ページングの停止条件まで実検証。Closes #3
テスト
npm run allgreen(github.test.ts 10 件)🤖 Generated with Claude Code
Summary by cubic
Add unit tests for
fetchJson(content-type guard) andcreateReleaseApi. They verify JSON parsing; treat HTML rate-limit pages as retryable with a repo-token hint; returnPermanentErroron 404; retry on 503; returntag_nameas-is ingetLatestVersion; and follow pagination while excluding drafts/prereleases inlistStableVersions.Written for commit daeceaf. Summary will update on new commits.