Browse Source

fix(nextcloud): add timeout to test setup

Signed-off-by: Nikolas Rimikis <rimikis.nikolas@gmail.com>
Signed-off-by: Nikolas Rimikis <leptopoda@users.noreply.github.com>
pull/603/head
Nikolas Rimikis 1 year ago committed by Nikolas Rimikis
parent
commit
d55a7b74fb
No known key found for this signature in database
GPG Key ID: 85ED1DE9786A4FF2
  1. 12
      packages/nextcloud/test/core_test.dart
  2. 13
      packages/nextcloud/test/helper.dart
  3. 12
      packages/nextcloud/test/news_test.dart
  4. 12
      packages/nextcloud/test/notes_test.dart
  5. 12
      packages/nextcloud/test/notifications_test.dart
  6. 12
      packages/nextcloud/test/provisioning_api_test.dart
  7. 12
      packages/nextcloud/test/uppush_test.dart
  8. 12
      packages/nextcloud/test/user_status_test.dart
  9. 13
      packages/nextcloud/test/webdav_test.dart

12
packages/nextcloud/test/core_test.dart

@ -1,13 +1,12 @@
@Retry(3)
library core_test;
import 'package:nextcloud/nextcloud.dart'; import 'package:nextcloud/nextcloud.dart';
import 'package:test/test.dart'; import 'package:test/test.dart';
import 'helper.dart'; import 'helper.dart';
void main() { void main() {
group('core', () { group(
'core',
() {
late DockerImage image; late DockerImage image;
setUpAll(() async => image = await getDockerImage()); setUpAll(() async => image = await getDockerImage());
@ -156,5 +155,8 @@ void main() {
expect(response.ocs.data.entries.single.rounded, isFalse); expect(response.ocs.data.entries.single.rounded, isFalse);
expect(response.ocs.data.entries.single.attributes, isEmpty); expect(response.ocs.data.entries.single.attributes, isEmpty);
}); });
}); },
retry: retryCount,
timeout: timeout,
);
} }

13
packages/nextcloud/test/helper.dart

@ -7,6 +7,9 @@ import 'package:nextcloud/nextcloud.dart';
import 'package:process_run/cmd_run.dart'; import 'package:process_run/cmd_run.dart';
import 'package:test/test.dart'; import 'package:test/test.dart';
const retryCount = 3;
const timeout = Timeout(Duration(seconds: 30));
class DockerContainer { class DockerContainer {
DockerContainer({ DockerContainer({
required this.id, required this.id,
@ -131,12 +134,18 @@ Future<TestNextcloudClient> getTestClient(
cookieJar: CookieJar(), cookieJar: CookieJar(),
); );
var i = 0;
while (true) { while (true) {
// Test will timeout after 30s
try { try {
await client.core.getStatus(); await client.core.getStatus();
break; break;
} catch (_) {} } on CoreApiException catch (error) {
i++;
await Future.delayed(const Duration(milliseconds: 100));
if (i >= 30) {
throw TimeoutException('Failed to get the status of the Server. $error');
}
}
} }
return client; return client;

12
packages/nextcloud/test/news_test.dart

@ -1,6 +1,3 @@
@Retry(3)
library news_test;
import 'dart:async'; import 'dart:async';
import 'dart:io'; import 'dart:io';
@ -10,7 +7,9 @@ import 'package:test/test.dart';
import 'helper.dart'; import 'helper.dart';
void main() { void main() {
group('news', () { group(
'news',
() {
late DockerImage image; late DockerImage image;
late HttpServer rssServer; late HttpServer rssServer;
setUpAll(() async { setUpAll(() async {
@ -268,7 +267,10 @@ void main() {
articlesResponse = await client.news.listArticles(type: NewsListType.unread.index); articlesResponse = await client.news.listArticles(type: NewsListType.unread.index);
expect(articlesResponse.items, hasLength(0)); expect(articlesResponse.items, hasLength(0));
}); });
}); },
retry: retryCount,
timeout: timeout,
);
} }
Future<HttpServer> getRssServer() async { Future<HttpServer> getRssServer() async {

12
packages/nextcloud/test/notes_test.dart

@ -1,13 +1,12 @@
@Retry(3)
library notes_test;
import 'package:nextcloud/nextcloud.dart'; import 'package:nextcloud/nextcloud.dart';
import 'package:test/test.dart'; import 'package:test/test.dart';
import 'helper.dart'; import 'helper.dart';
void main() { void main() {
group('notes', () { group(
'notes',
() {
late DockerImage image; late DockerImage image;
setUpAll(() async => image = await getDockerImage()); setUpAll(() async => image = await getDockerImage());
@ -139,5 +138,8 @@ void main() {
expect(response.fileSuffix, '.txt'); expect(response.fileSuffix, '.txt');
expect(response.noteMode, NotesSettings_NoteMode.preview); expect(response.noteMode, NotesSettings_NoteMode.preview);
}); });
}); },
retry: retryCount,
timeout: timeout,
);
} }

12
packages/nextcloud/test/notifications_test.dart

@ -1,6 +1,3 @@
@Retry(3)
library notifications_test;
import 'dart:async'; import 'dart:async';
import 'package:nextcloud/nextcloud.dart'; import 'package:nextcloud/nextcloud.dart';
@ -99,7 +96,9 @@ void main() {
}); });
}); });
group('push notifications', () { group(
'push notifications',
() {
late DockerImage image; late DockerImage image;
setUpAll(() async => image = await getDockerImage()); setUpAll(() async => image = await getDockerImage());
@ -137,5 +136,8 @@ void main() {
await client.notifications.removeDevice(); await client.notifications.removeDevice();
}); });
}); },
retry: retryCount,
timeout: timeout,
);
} }

12
packages/nextcloud/test/provisioning_api_test.dart

@ -1,12 +1,11 @@
@Retry(3)
library provisioning_api_test;
import 'package:test/test.dart'; import 'package:test/test.dart';
import 'helper.dart'; import 'helper.dart';
void main() { void main() {
group('provisioning_api', () { group(
'provisioning_api',
() {
late DockerImage image; late DockerImage image;
setUpAll(() async => image = await getDockerImage()); setUpAll(() async => image = await getDockerImage());
@ -50,5 +49,8 @@ void main() {
} }
}); });
}); });
}); },
retry: retryCount,
timeout: timeout,
);
} }

12
packages/nextcloud/test/uppush_test.dart

@ -1,12 +1,11 @@
@Retry(3)
library uppush_test;
import 'package:test/test.dart'; import 'package:test/test.dart';
import 'helper.dart'; import 'helper.dart';
void main() { void main() {
group('uppush', () { group(
'uppush',
() {
late DockerImage image; late DockerImage image;
setUpAll(() async => image = await getDockerImage()); setUpAll(() async => image = await getDockerImage());
@ -63,5 +62,8 @@ void main() {
}); });
// Deleting an app, sending a notification (also via matrix gateway) or listening for notifications is not possible because redis is not set up // Deleting an app, sending a notification (also via matrix gateway) or listening for notifications is not possible because redis is not set up
}); },
retry: retryCount,
timeout: timeout,
);
} }

12
packages/nextcloud/test/user_status_test.dart

@ -1,13 +1,12 @@
@Retry(3)
library user_status_test;
import 'package:nextcloud/nextcloud.dart'; import 'package:nextcloud/nextcloud.dart';
import 'package:test/test.dart'; import 'package:test/test.dart';
import 'helper.dart'; import 'helper.dart';
void main() { void main() {
group('user_status', () { group(
'user_status',
() {
late DockerImage image; late DockerImage image;
setUpAll(() async => image = await getDockerImage()); setUpAll(() async => image = await getDockerImage());
@ -170,5 +169,8 @@ void main() {
expect(response.ocs.data.public.status, 'online'); expect(response.ocs.data.public.status, 'online');
expect(response.ocs.data.private1.statusIsUserDefined, false); expect(response.ocs.data.private1.statusIsUserDefined, false);
}); });
}); },
retry: retryCount,
timeout: timeout,
);
} }

13
packages/nextcloud/test/webdav_test.dart

@ -1,6 +1,3 @@
@Retry(3)
library webdav_test;
import 'dart:convert'; import 'dart:convert';
import 'dart:io'; import 'dart:io';
import 'dart:math'; import 'dart:math';
@ -26,12 +23,15 @@ void main() {
expect(() => WebDavClient.constructUri(baseURL), throwsA(isA<AssertionError>())); expect(() => WebDavClient.constructUri(baseURL), throwsA(isA<AssertionError>()));
}); });
group('webdav', () { group(
'webdav',
() {
late DockerImage image; late DockerImage image;
setUpAll(() async => image = await getDockerImage()); setUpAll(() async => image = await getDockerImage());
late DockerContainer container; late DockerContainer container;
late TestNextcloudClient client; late TestNextcloudClient client;
setUp(() async { setUp(() async {
container = await getDockerContainer(image); container = await getDockerContainer(image);
client = await getTestClient(container); client = await getTestClient(container);
@ -529,5 +529,8 @@ void main() {
// props: Most of them are either not applicable or hard/impossible to implement because we don't allow just writing any props // props: Most of them are either not applicable or hard/impossible to implement because we don't allow just writing any props
}); });
}); },
retry: retryCount,
timeout: timeout,
);
} }

Loading…
Cancel
Save