Add unit tests for findUniqueFileName#6623
Add unit tests for findUniqueFileName#6623Kota-Jagadeesh wants to merge 12 commits intocommons-app:mainfrom
Conversation
|
Do we really want to go with the hash ("#") format? The information in #5923 might have been outdated in some part. I think "#" in file names would not be great as @nicolas-raoul said: #5877 (review) |
@whym I uunderstand that the |
|
I would leave it as it is (using parentheses), if the point here is to add unit tests. If there is a good reason to change it again, to the dash mark or something else, we can consider it later. The change from "#" to "()" was done in #6086 . |
|
@whym I have reverted the naming logic to the original 5-digit parentheses format and updated the unit tests to match. |
app/src/test/kotlin/fr/free/nrw/commons/upload/worker/UploadWorkerTest.kt
Outdated
Show resolved
Hide resolved
| @Before | ||
| fun setUp() { | ||
| MockitoAnnotations.openMocks(this) | ||
| uploadWorker = mock<UploadWorker>() |
There was a problem hiding this comment.
I think testing against a mocked instance should be avoided where possible.
It seems like findUniqueFileName can be easier to test if it's extracted from UploadWorker, and placed in one of the util-like classes or a new one, if there is no suitable one. (MediaDataExtractor.kt?) What do you think?
|
✅ Generated APK variants! |
Description (required)
Fixes #5923
What changes did you make and why?
findUniqueFileNameinUploadWorker.ktto replace the old 5-digit random hash format(12345)with the requested 3-digit hash format#XXX.UploadWorkerTest.ktto ensure the filename generation logic is robust.findUniqueFileNamevisibility tointernalto allow unit test access while maintaining module-level encapsulation.Why?
The previous 5-digit format did not meeet the updated project requirements. these changes align the naming convention with the
#XXXstandard and provide automated testing to ensure filenames are generated correctly and remain unique.Tests performed (required)
Tested ProdDebug build variant on Local Unit Tests (JUnit 4).