-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
[TECHNICAL] Unit tests for repository classes - Part 4 #4537
base: master
Are you sure you want to change the base?
Conversation
2f77fbb
to
cd05b19
Compare
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.
Some changes requested here @joragua! 👍
val OC_USER_QUOTA_WITHOUT_PERSONAL = UserQuota( | ||
accountName = OC_ACCOUNT_NAME, | ||
used = 0, | ||
available = -4L, | ||
total = 0, | ||
state = UserQuotaState.NORMAL | ||
) | ||
|
||
val OC_USER_QUOTA_UNLIMITED = UserQuota( | ||
accountName = OC_ACCOUNT_NAME, | ||
used = 5_000, | ||
available = -3L, | ||
total = 0, | ||
state = UserQuotaState.NORMAL | ||
) |
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.
It would be clearer if you wrote the parameters in the same order as in the implementation: accountName
, available
, used
, total
and state
, like that. That way, when we want to compare with the implementation, it will be a direct mapping 👍
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.
Done ✅
fun `getSpaceByIdForAccount returns an OCSpace`() { | ||
every { | ||
localSpacesDataSource.getSpaceByIdForAccount(OC_SPACE_PROJECT_WITH_IMAGE.id, OC_ACCOUNT_NAME) | ||
} returns OC_SPACE_PROJECT_WITH_IMAGE |
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.
This one has specials in it. Check if there is any other example space that has no specials and use it, otherwise the content of this test (and the method) is the same as the previous one
} | ||
|
||
@Test | ||
fun `updateTransferStatusToInProgressById updates a transfer in progress by its id correctly`() { |
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.
More than updating a transfer in progress, this is intended to update a transfer's status to "in progress", so you could mention that the status is changed (check OCLocalTransferDataSourceTest
)
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.
Changed 👍🏻
} | ||
|
||
@Test | ||
fun `updateTransferStatusToEnqueuedById updates a transfer in queue by its id correctly`() { |
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.
Same as the previous test
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.
Done
} | ||
|
||
@Test | ||
fun `updateTransferWhenFinished updates a finished transfer correctly `() { |
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.
fun `updateTransferWhenFinished updates a finished transfer correctly `() { | |
fun `updateTransferWhenFinished updates a finished transfer correctly`() { |
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.
Removed
} | ||
|
||
@Test | ||
fun `getCurrentAndPendingTransfers returns a list of pending and in progress OCTransfer`() { |
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.
fun `getCurrentAndPendingTransfers returns a list of pending and in progress OCTransfer`() { | |
fun `getCurrentAndPendingTransfers returns a list of OCTransfer`() { |
No need to specify semantically if not needed
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.
Removed!
@Test | ||
fun `getStoredUserQuotaAsFlow returns a Flow with null when local datasource returns a Flow with null`() = runTest { | ||
every { | ||
localUserDataSource.getQuotaForAccountAsFlow(OC_ACCOUNT_NAME) | ||
} returns flowOf(null) | ||
|
||
val userQuota = ocUserRepository.getStoredUserQuotaAsFlow(OC_ACCOUNT_NAME).first() | ||
assertNull(userQuota) | ||
|
||
ocUserRepository.getStoredUserQuota(OC_ACCOUNT_NAME) | ||
verify(exactly = 1) { | ||
localUserDataSource.getQuotaForAccountAsFlow(OC_ACCOUNT_NAME) | ||
} | ||
} |
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.
Not needed
* | ||
* @author Jorge Aguado Recio | ||
* | ||
* Copyright (C) 2024 ownCloud GmbH. |
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.
BTW, it's already 2025 🙂
remoteWebFingerDatasource.getInstancesFromWebFinger( | ||
OC_SECURE_SERVER_INFO_BASIC_AUTH.baseUrl, | ||
WebFingerRel.OIDC_ISSUER_DISCOVERY, | ||
OC_SECURE_SERVER_INFO_BASIC_AUTH.baseUrl |
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.
The resource is usually the webfinger username. You can adapt this so that it looks a bit more realistic 👍
remoteWebFingerDatasource.getInstancesFromAuthenticatedWebFinger( | ||
OC_SECURE_SERVER_INFO_BASIC_AUTH.baseUrl, | ||
WebFingerRel.OIDC_ISSUER_DISCOVERY, | ||
OC_SECURE_SERVER_INFO_BASIC_AUTH.baseUrl, |
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.
This also has a different structure. Check GetOwnCloudInstancesFromAuthenticatedWebFingerUseCase
d15020c
to
4f1701a
Compare
Related Issues
App:
ReleaseNotesViewModel.kt
creating a newReleaseNote()
with String resources (if required)QA