🧪 [Add tests for UpdateChecker error handling] - #193
Conversation
Co-authored-by: alvin000009238 <107313913+alvin000009238@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
There was a problem hiding this comment.
Code Review
This pull request adds a new test case to UpdateCheckerTest.kt to verify that network exceptions without a message return a default error. However, several temporary and backup files (.orig, .rej, and .patch) were accidentally committed. The feedback correctly advises removing these unnecessary files from the repository.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| @@ -0,0 +1,23 @@ | |||
| --- android/app/src/test/java/com/clhs/score/data/UpdateCheckerTest.kt | |||
| @@ -0,0 +1,28 @@ | |||
| --- UpdateCheckerTest.kt | |||
| @@ -0,0 +1,162 @@ | |||
| package com.clhs.score.data | |||
There was a problem hiding this comment.
Pull request overview
This PR aims to improve confidence in the Android app’s update-check flow by adding unit tests that exercise UpdateChecker error paths (network exceptions and non-2xx HTTP responses) and validate the resulting UpdateResult.Error(...) messages.
Changes:
- Added test coverage for network exceptions with/without an exception message, asserting the fallback message
"未知錯誤"is used when needed. - Added/validated test coverage for non-successful HTTP responses (e.g.,
404) returningUpdateResult.Error("HTTP 404"). - Included extra patch/backup artifacts (
fix_test.patch,UpdateCheckerTest.kt.orig,UpdateCheckerTest.kt.rej) that should not be committed.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| android/app/src/test/java/com/clhs/score/data/UpdateCheckerTest.kt | Adds/extends tests for UpdateChecker error handling (IOException + HTTP non-success). |
| fix_test.patch | Patch artifact added to repo (should be removed). |
| android/app/src/test/java/com/clhs/score/data/UpdateCheckerTest.kt.orig | Backup artifact added to repo (should be removed). |
| android/app/src/test/java/com/clhs/score/data/UpdateCheckerTest.kt.rej | Patch reject artifact added to repo (should be removed). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| --- android/app/src/test/java/com/clhs/score/data/UpdateCheckerTest.kt | ||
| +++ android/app/src/test/java/com/clhs/score/data/UpdateCheckerTest.kt | ||
| @@ -128,6 +128,20 @@ | ||
| assertEquals(UpdateResult.Error("HTTP 404"), checker().check("1.1.9")) | ||
| } |
| package com.clhs.score.data | ||
|
|
||
| import kotlinx.coroutines.test.runTest | ||
| import okhttp3.OkHttpClient | ||
| import okhttp3.mockwebserver.MockResponse |
| --- UpdateCheckerTest.kt | ||
| +++ UpdateCheckerTest.kt | ||
| @@ -137,14 +137,14 @@ | ||
| latestReleaseUrl = server.url("/release/latest").toString(), | ||
| ) | ||
|
|
🎯 What
Added tests for error handling logic in
UpdateChecker.ktto ensure network exceptions and non-successful HTTP responses are gracefully handled.📊 Coverage
IOExceptionreturningUpdateResult.Error(message).UpdateResult.Error("未知錯誤").UpdateResult.Error("HTTP 404").✨ Result
Increased test coverage in
UpdateChecker.ktby fully exercising thecatch (e: Exception)block and the HTTP non-successful check.PR created automatically by Jules for task 1046998404765757144 started by @alvin000009238