Skip to content

Commit f55dbde

Browse files
committed
test: create new tests for OCShareRepositoryTest and OCRemoteShareDataSourceTest
Signed-off-by: Jorge Aguado Recio <jaguado@izertis.com>
1 parent adbcb73 commit f55dbde

2 files changed

Lines changed: 59 additions & 0 deletions

File tree

‎owncloudData/src/test/java/com/owncloud/android/data/sharing/shares/datasources/implementation/OCRemoteShareDataSourceTest.kt‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ class OCRemoteShareDataSourceTest {
5656
private val clientManager: ClientManager = mockk(relaxed = true)
5757

5858
private val userType = OCMemberType.toString(OC_USER_MEMBER.type).lowercase()
59+
private val shareId = "share-id"
5960

6061
@Before
6162
fun setUp() {
@@ -450,6 +451,35 @@ class OCRemoteShareDataSourceTest {
450451
}
451452
}
452453

454+
@Test
455+
fun `removeGraphShare removes a graph share correctly`() {
456+
val removeGraphShareResult = createRemoteOperationResultMock(Unit, isSuccess = true)
457+
458+
every {
459+
ocShareService.removeGraphShare(
460+
spaceId = OC_SPACE_PROJECT_WITH_IMAGE.id,
461+
itemId = OC_FILE.remoteId.orEmpty(),
462+
shareId = shareId
463+
)
464+
} returns removeGraphShareResult
465+
466+
ocRemoteShareDataSource.removeGraphShare(
467+
accountName = OC_ACCOUNT_NAME,
468+
spaceId = OC_SPACE_PROJECT_WITH_IMAGE.id,
469+
itemId = OC_FILE.remoteId.orEmpty(),
470+
shareId = shareId
471+
)
472+
473+
verify(exactly = 1) {
474+
clientManager.getShareService(OC_ACCOUNT_NAME)
475+
ocShareService.removeGraphShare(
476+
spaceId = OC_SPACE_PROJECT_WITH_IMAGE.id,
477+
itemId = OC_FILE.remoteId.orEmpty(),
478+
shareId = shareId
479+
)
480+
}
481+
}
482+
453483
@Test(expected = ShareNotFoundException::class)
454484
fun `insert throws a ShareNotFoundException when share is not found`() {
455485
insertShareOperationWithError(RemoteOperationResult.ResultCode.SHARE_NOT_FOUND)

‎owncloudData/src/test/java/com/owncloud/android/data/sharing/shares/repository/OCShareRepositoryTest.kt‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ class OCShareRepositoryTest {
6161
private val password = "password"
6262
private val permissions = OC_SHARE.permissions
6363
private val expiration = RemoteShare.INIT_EXPIRATION_DATE_IN_MILLIS
64+
private val shareId = "share-id"
6465

6566
@Test
6667
fun `insertPrivateShare inserts a private OCShare correctly`() {
@@ -291,6 +292,34 @@ class OCShareRepositoryTest {
291292
}
292293
}
293294

295+
@Test
296+
fun `removeGraphShare removes a share correctly`() {
297+
every {
298+
remoteShareDataSource.removeGraphShare(
299+
accountName = OC_ACCOUNT_NAME,
300+
spaceId = OC_SPACE_PROJECT_WITH_IMAGE.id,
301+
itemId = OC_FILE.remoteId.orEmpty(),
302+
shareId = shareId
303+
)
304+
} returns Unit
305+
306+
ocShareRepository.removeGraphShare(
307+
accountName = OC_ACCOUNT_NAME,
308+
spaceId = OC_SPACE_PROJECT_WITH_IMAGE.id,
309+
itemId = OC_FILE.remoteId.orEmpty(),
310+
shareId = shareId
311+
)
312+
313+
verify(exactly = 1) {
314+
remoteShareDataSource.removeGraphShare(
315+
accountName = OC_ACCOUNT_NAME,
316+
spaceId = OC_SPACE_PROJECT_WITH_IMAGE.id,
317+
itemId = OC_FILE.remoteId.orEmpty(),
318+
shareId = shareId
319+
)
320+
}
321+
}
322+
294323
@Test
295324
fun `refreshSharesFromNetwork refreshes shares correctly when the list of shares received is not empty`() {
296325
every {

0 commit comments

Comments
 (0)