Skip to content

Commit b96d0ea

Browse files
committed
Check Capability and server version for tests
Signed-off-by: alperozturk <[email protected]>
1 parent b0f7680 commit b96d0ea

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

app/src/androidTest/java/com/nextcloud/client/assistant/AssistantRepositoryTests.kt

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ package com.nextcloud.client.assistant
2323

2424
import com.nextcloud.client.assistant.repository.AssistantRepository
2525
import com.owncloud.android.AbstractOnServerIT
26+
import com.owncloud.android.lib.resources.status.NextcloudVersion
2627
import org.junit.Assert.assertTrue
2728
import org.junit.Before
2829
import org.junit.Test
@@ -39,6 +40,12 @@ class AssistantRepositoryTests : AbstractOnServerIT() {
3940

4041
@Test
4142
fun testGetTaskTypes() {
43+
testOnlyOnServer(NextcloudVersion.nextcloud_28)
44+
45+
if (capability.assistant.isFalse) {
46+
return
47+
}
48+
4249
val result = sut?.getTaskTypes()
4350
assertTrue(result?.isSuccess == true)
4451

@@ -48,6 +55,12 @@ class AssistantRepositoryTests : AbstractOnServerIT() {
4855

4956
@Test
5057
fun testGetTaskList() {
58+
testOnlyOnServer(NextcloudVersion.nextcloud_28)
59+
60+
if (capability.assistant.isFalse) {
61+
return
62+
}
63+
5164
val result = sut?.getTaskList("assistant")
5265
assertTrue(result?.isSuccess == true)
5366

@@ -57,6 +70,12 @@ class AssistantRepositoryTests : AbstractOnServerIT() {
5770

5871
@Test
5972
fun testCreateTask() {
73+
testOnlyOnServer(NextcloudVersion.nextcloud_28)
74+
75+
if (capability.assistant.isFalse) {
76+
return
77+
}
78+
6079
val input = "Give me some random output for test purpose"
6180
val type = "OCP\\TextProcessing\\FreePromptTaskType"
6281
val result = sut?.createTask(input, type)
@@ -65,6 +84,12 @@ class AssistantRepositoryTests : AbstractOnServerIT() {
6584

6685
@Test
6786
fun testDeleteTask() {
87+
testOnlyOnServer(NextcloudVersion.nextcloud_28)
88+
89+
if (capability.assistant.isFalse) {
90+
return
91+
}
92+
6893
testCreateTask()
6994

7095
sleep(120)

app/src/androidTest/java/com/owncloud/android/AbstractIT.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,13 +195,18 @@ public static void beforeAll() {
195195
}
196196

197197
protected void testOnlyOnServer(OwnCloudVersion version) throws AccountUtils.AccountNotFoundException {
198+
OCCapability ocCapability = getCapability();
199+
assumeTrue(ocCapability.getVersion().isNewerOrEqual(version));
200+
}
201+
202+
protected OCCapability getCapability() throws AccountUtils.AccountNotFoundException {
198203
NextcloudClient client = OwnCloudClientFactory.createNextcloudClient(user, targetContext);
199204

200205
OCCapability ocCapability = (OCCapability) new GetCapabilitiesRemoteOperation()
201206
.execute(client)
202207
.getSingleData();
203208

204-
assumeTrue(ocCapability.getVersion().isNewerOrEqual(version));
209+
return ocCapability;
205210
}
206211

207212
@Before

0 commit comments

Comments
 (0)