Browse Source

feat(nextcloud): Allow using apache as web server for tests

pull/486/head
jld3103 1 year ago
parent
commit
1aa6b304c0
No known key found for this signature in database
GPG Key ID: 9062417B9E8EB7B3
  1. 16
      packages/nextcloud/test/helper.dart
  2. 10
      packages/nextcloud/test/news_test.dart

16
packages/nextcloud/test/helper.dart

@ -144,7 +144,7 @@ Future<TestNextcloudClient> getTestClient(
return client; return client;
} }
Future<DockerContainer> getDockerContainer(final DockerImage image) async { Future<DockerContainer> getDockerContainer(final DockerImage image, {final bool useApache = false}) async {
late ProcessResult result; late ProcessResult result;
late int port; late int port;
while (true) { while (true) {
@ -155,12 +155,16 @@ Future<DockerContainer> getDockerContainer(final DockerImage image) async {
'run', 'run',
'--rm', '--rm',
'-d', '-d',
'--net', '--add-host',
'host', 'host.docker.internal:host-gateway',
'-p',
'$port:80',
image, image,
'php', if (!useApache) ...[
'-S', 'php',
'0.0.0.0:$port', '-S',
'0.0.0.0:80',
],
], ],
); );
// 125 means the docker run command itself has failed which indicated the port is already used // 125 means the docker run command itself has failed which indicated the port is already used

10
packages/nextcloud/test/news_test.dart

@ -25,12 +25,12 @@ Future run(final DockerImage image) async {
tearDown(() => container.destroy()); tearDown(() => container.destroy());
Future<NewsListFeeds> addWikipediaFeed([final int? folderID]) => client.news.addFeed( Future<NewsListFeeds> addWikipediaFeed([final int? folderID]) => client.news.addFeed(
url: 'http://localhost:${rssServer.port}/wikipedia.xml', url: 'http://host.docker.internal:${rssServer.port}/wikipedia.xml',
folderId: folderID, folderId: folderID,
); );
Future<NewsListFeeds> addNasaFeed() => client.news.addFeed( Future<NewsListFeeds> addNasaFeed() => client.news.addFeed(
url: 'http://localhost:${rssServer.port}/nasa.xml', url: 'http://host.docker.internal:${rssServer.port}/nasa.xml',
); );
test('Is supported', () async { test('Is supported', () async {
@ -48,13 +48,13 @@ Future run(final DockerImage image) async {
expect(response.starredCount, null); expect(response.starredCount, null);
expect(response.newestItemId, isNotNull); expect(response.newestItemId, isNotNull);
expect(response.feeds, hasLength(1)); expect(response.feeds, hasLength(1));
expect(response.feeds[0].url, 'http://localhost:${rssServer.port}/wikipedia.xml'); expect(response.feeds[0].url, 'http://host.docker.internal:${rssServer.port}/wikipedia.xml');
response = await client.news.listFeeds(); response = await client.news.listFeeds();
expect(response.starredCount, 0); expect(response.starredCount, 0);
expect(response.newestItemId, isNotNull); expect(response.newestItemId, isNotNull);
expect(response.feeds, hasLength(1)); expect(response.feeds, hasLength(1));
expect(response.feeds[0].url, 'http://localhost:${rssServer.port}/wikipedia.xml'); expect(response.feeds[0].url, 'http://host.docker.internal:${rssServer.port}/wikipedia.xml');
}); });
test('Rename feed', () async { test('Rename feed', () async {
@ -247,7 +247,7 @@ Future run(final DockerImage image) async {
expect(response.newestItemId, isNotNull); expect(response.newestItemId, isNotNull);
expect(response.feeds, hasLength(1)); expect(response.feeds, hasLength(1));
expect(response.feeds[0].folderId, 1); expect(response.feeds[0].folderId, 1);
expect(response.feeds[0].url, 'http://localhost:${rssServer.port}/wikipedia.xml'); expect(response.feeds[0].url, 'http://host.docker.internal:${rssServer.port}/wikipedia.xml');
}); });
test('Mark folder as read', () async { test('Mark folder as read', () async {

Loading…
Cancel
Save