-
Notifications
You must be signed in to change notification settings - Fork 273
π§ͺ test: add isInRollout boundary tests #524
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| sed -i '365s/info: CheckResult/updateInfo: CheckResult/' src/client.ts | ||
| sed -i '368s/info.updateUrl/updateInfo.updateUrl/' src/client.ts | ||
| sed -i '369s/info.hash/updateInfo.hash/' src/client.ts | ||
| sed -i '381s/info.hash/updateInfo.hash/' src/client.ts | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| sed -i 's/} = info;/} = updateInfo;/' src/client.ts | ||
| sed -i 's/beforeDownloadUpdate(info)/beforeDownloadUpdate(updateInfo)/' src/client.ts | ||
| sed -i 's/if (!info.update || !hash) {/if (!updateInfo.update || !hash) {/' src/client.ts |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| sed -i 's/await import('\''\.\.\/isInRollout?deterministic'\'')/await import('\''\.\.\/isInRollout?deterministic'\'' \/\* @vite-ignore \*\/) as any/' src/__tests__/isInRollout.test.ts | ||
| sed -i 's/await import('\''\.\.\/core?error'\'')/await import('\''\.\.\/core?error'\'' \/\* @vite-ignore \*\/) as any/' src/__tests__/core.test.ts | ||
| sed -i 's/await import('\''\.\.\/core?success'\'')/await import('\''\.\.\/core?success'\'' \/\* @vite-ignore \*\/) as any/' src/__tests__/core.test.ts |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| import { describe, expect, test, mock, beforeAll } from 'bun:test'; | ||
|
|
||
| mock.module('../core', () => { | ||
| return { | ||
| cInfo: { | ||
| uuid: 'fixed-test-uuid', | ||
| }, | ||
| }; | ||
| }); | ||
|
|
||
| describe('isInRollout', () => { | ||
| let isInRollout: (rollout: number) => boolean; | ||
|
|
||
| beforeAll(async () => { | ||
| // Dynamic import to ensure the mock is picked up | ||
| // @ts-ignore | ||
| const module = await import('../isInRollout?deterministic'); | ||
| isInRollout = module.isInRollout; | ||
| }); | ||
|
|
||
| test('returns false when rollout is 0', () => { | ||
| expect(isInRollout(0)).toBe(false); | ||
| }); | ||
|
|
||
| test('returns false when rollout is less than or equal to the hash modulo (79)', () => { | ||
| // 79 < 79 is false | ||
| expect(isInRollout(79)).toBe(false); | ||
| }); | ||
|
|
||
| test('returns true when rollout is strictly greater than the hash modulo (80)', () => { | ||
| // 79 < 80 is true | ||
| expect(isInRollout(80)).toBe(true); | ||
| }); | ||
|
|
||
| test('returns true when rollout is 100', () => { | ||
| expect(isInRollout(100)).toBe(true); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
π§© Analysis chain
π Script executed:
Repository: reactnativecn/react-native-update
Length of output: 214
These line-numbered rewrites are already out of sync with
src/client.ts.On the checked-in file, Lines 368, 369, and 381 no longer contain the
info.updateUrl/info.hashtext this script expects, so it can exit successfully while applying nothing. Use content-based replacements and assert that each rewrite happened.Suggested direction
π Committable suggestion
π§° Tools
πͺ Shellcheck (0.11.0)
[error] 1-1: Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.
(SC2148)
π€ Prompt for AI Agents