Skip to content

Commit 04333a5

Browse files
committed
test: create new tests for OCLinksRepositoryTest and OCRemoteLinksDataSourceTest
1 parent 1df787c commit 04333a5

2 files changed

Lines changed: 126 additions & 0 deletions

File tree

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

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,70 @@ class OCRemoteLinksDataSourceTest {
8383
}
8484
}
8585

86+
@Test
87+
fun `editLink edits a public link from a project space correctly`() {
88+
val editLinkResult = createRemoteOperationResultMock(Unit, isSuccess = true)
89+
90+
every {
91+
ocLinksService.editLink(
92+
spaceId = OC_SPACE_PROJECT_WITH_IMAGE.id,
93+
linkId = SPACE_MEMBERS.links[0].id,
94+
displayName = SPACE_MEMBERS.links[0].displayName,
95+
type = OCLinkType.toString(SPACE_MEMBERS.links[0].type),
96+
expirationDate = SPACE_MEMBERS.links[0].expirationDateTime
97+
)
98+
} returns editLinkResult
99+
100+
ocRemoteLinksDataSource.editLink(
101+
accountName = OC_ACCOUNT_NAME,
102+
spaceId = OC_SPACE_PROJECT_WITH_IMAGE.id,
103+
linkId = SPACE_MEMBERS.links[0].id,
104+
displayName = SPACE_MEMBERS.links[0].displayName,
105+
type = SPACE_MEMBERS.links[0].type,
106+
expirationDate = SPACE_MEMBERS.links[0].expirationDateTime
107+
)
108+
109+
verify(exactly = 1) {
110+
clientManager.getLinksService(OC_ACCOUNT_NAME)
111+
ocLinksService.editLink(
112+
spaceId = OC_SPACE_PROJECT_WITH_IMAGE.id,
113+
linkId = SPACE_MEMBERS.links[0].id,
114+
displayName = SPACE_MEMBERS.links[0].displayName,
115+
type = OCLinkType.toString(SPACE_MEMBERS.links[0].type),
116+
expirationDate = SPACE_MEMBERS.links[0].expirationDateTime
117+
)
118+
}
119+
}
120+
121+
@Test
122+
fun `editPasswordLink edits the password of a public link from a project space correctly`() {
123+
val editPasswordLinkResult = createRemoteOperationResultMock(Unit, isSuccess = true)
124+
125+
every {
126+
ocLinksService.editPasswordLink(
127+
spaceId = OC_SPACE_PROJECT_WITH_IMAGE.id,
128+
linkId = SPACE_MEMBERS.links[0].id,
129+
password = password
130+
)
131+
} returns editPasswordLinkResult
132+
133+
ocRemoteLinksDataSource.editPasswordLink(
134+
accountName = OC_ACCOUNT_NAME,
135+
spaceId = OC_SPACE_PROJECT_WITH_IMAGE.id,
136+
linkId = SPACE_MEMBERS.links[0].id,
137+
password = password
138+
)
139+
140+
verify(exactly = 1) {
141+
clientManager.getLinksService(OC_ACCOUNT_NAME)
142+
ocLinksService.editPasswordLink(
143+
spaceId = OC_SPACE_PROJECT_WITH_IMAGE.id,
144+
linkId = SPACE_MEMBERS.links[0].id,
145+
password = password
146+
)
147+
}
148+
}
149+
86150
@Test
87151
fun `removeLink removes a public link from a project space correctly`() {
88152
val removeLinkResult = createRemoteOperationResultMock(Unit, isSuccess = true)

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

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,68 @@ class OCLinksRepositoryTest {
7070
}
7171
}
7272

73+
@Test
74+
fun `editLink edits a public link from a space correctly`() {
75+
every {
76+
remoteLinksDataSource.editLink(
77+
accountName = OC_ACCOUNT_NAME,
78+
spaceId = OC_SPACE_PROJECT_WITH_IMAGE.id,
79+
linkId = SPACE_MEMBERS.links[0].id,
80+
displayName = SPACE_MEMBERS.links[0].displayName,
81+
type = SPACE_MEMBERS.links[0].type,
82+
expirationDate = SPACE_MEMBERS.links[0].expirationDateTime
83+
)
84+
} returns Unit
85+
86+
ocLinksRepository.editLink(
87+
accountName = OC_ACCOUNT_NAME,
88+
spaceId = OC_SPACE_PROJECT_WITH_IMAGE.id,
89+
linkId = SPACE_MEMBERS.links[0].id,
90+
displayName = SPACE_MEMBERS.links[0].displayName,
91+
type = SPACE_MEMBERS.links[0].type,
92+
expirationDate = SPACE_MEMBERS.links[0].expirationDateTime
93+
)
94+
95+
verify(exactly = 1) {
96+
remoteLinksDataSource.editLink(
97+
accountName = OC_ACCOUNT_NAME,
98+
spaceId = OC_SPACE_PROJECT_WITH_IMAGE.id,
99+
linkId = SPACE_MEMBERS.links[0].id,
100+
displayName = SPACE_MEMBERS.links[0].displayName,
101+
type = SPACE_MEMBERS.links[0].type,
102+
expirationDate = SPACE_MEMBERS.links[0].expirationDateTime
103+
)
104+
}
105+
}
106+
107+
@Test
108+
fun `editPasswordLink edits the password of a public link from a space correctly`() {
109+
every {
110+
remoteLinksDataSource.editPasswordLink(
111+
accountName = OC_ACCOUNT_NAME,
112+
spaceId = OC_SPACE_PROJECT_WITH_IMAGE.id,
113+
linkId = SPACE_MEMBERS.links[0].id,
114+
password = password
115+
)
116+
} returns Unit
117+
118+
ocLinksRepository.editPasswordLink(
119+
accountName = OC_ACCOUNT_NAME,
120+
spaceId = OC_SPACE_PROJECT_WITH_IMAGE.id,
121+
linkId = SPACE_MEMBERS.links[0].id,
122+
password = password
123+
)
124+
125+
verify(exactly = 1) {
126+
remoteLinksDataSource.editPasswordLink(
127+
accountName = OC_ACCOUNT_NAME,
128+
spaceId = OC_SPACE_PROJECT_WITH_IMAGE.id,
129+
linkId = SPACE_MEMBERS.links[0].id,
130+
password = password
131+
)
132+
}
133+
}
134+
73135
@Test
74136
fun `removeLink removes a public link from a space correctly`() {
75137
every {

0 commit comments

Comments
 (0)