Skip to content

Commit 523f5e7

Browse files
committed
test: create new tests for OCLinksRepositoryTest and OCRemoteLinksDataSourceTest
1 parent f37c493 commit 523f5e7

2 files changed

Lines changed: 51 additions & 0 deletions

File tree

owncloudData/src/test/java/com/owncloud/android/data/links/datasources/implementation/OCRemoteLinksDataSourceTest.kt

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,4 +82,30 @@ class OCRemoteLinksDataSourceTest {
8282
)
8383
}
8484
}
85+
86+
@Test
87+
fun `removeLink removes a public link from a project space correctly`() {
88+
val removeLinkResult = createRemoteOperationResultMock(Unit, isSuccess = true)
89+
90+
every {
91+
ocLinksService.removeLink(
92+
spaceId = OC_SPACE_PROJECT_WITH_IMAGE.id,
93+
linkId = SPACE_MEMBERS.links[0].id
94+
)
95+
} returns removeLinkResult
96+
97+
ocRemoteLinksDataSource.removeLink(
98+
accountName = OC_ACCOUNT_NAME,
99+
spaceId = OC_SPACE_PROJECT_WITH_IMAGE.id,
100+
linkId = SPACE_MEMBERS.links[0].id
101+
)
102+
103+
verify(exactly = 1) {
104+
clientManager.getLinksService(OC_ACCOUNT_NAME)
105+
ocLinksService.removeLink(
106+
spaceId = OC_SPACE_PROJECT_WITH_IMAGE.id,
107+
linkId = SPACE_MEMBERS.links[0].id
108+
)
109+
}
110+
}
85111
}

owncloudData/src/test/java/com/owncloud/android/data/links/repository/OCLinksRepositoryTest.kt

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,29 @@ class OCLinksRepositoryTest {
6969
)
7070
}
7171
}
72+
73+
@Test
74+
fun `removeLink removes a public link from a space correctly`() {
75+
every {
76+
remoteLinksDataSource.removeLink(
77+
accountName = OC_ACCOUNT_NAME,
78+
spaceId = OC_SPACE_PROJECT_WITH_IMAGE.id,
79+
linkId = SPACE_MEMBERS.links[0].id
80+
)
81+
} returns Unit
82+
83+
ocLinksRepository.removeLink(
84+
accountName = OC_ACCOUNT_NAME,
85+
spaceId = OC_SPACE_PROJECT_WITH_IMAGE.id,
86+
linkId = SPACE_MEMBERS.links[0].id
87+
)
88+
89+
verify(exactly = 1) {
90+
remoteLinksDataSource.removeLink(
91+
accountName = OC_ACCOUNT_NAME,
92+
spaceId = OC_SPACE_PROJECT_WITH_IMAGE.id,
93+
linkId = SPACE_MEMBERS.links[0].id
94+
)
95+
}
96+
}
7297
}

0 commit comments

Comments
 (0)