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. 12
      packages/nextcloud/test/helper.dart
  2. 10
      packages/nextcloud/test/news_test.dart

12
packages/nextcloud/test/helper.dart

@ -144,7 +144,7 @@ Future<TestNextcloudClient> getTestClient(
return client;
}
Future<DockerContainer> getDockerContainer(final DockerImage image) async {
Future<DockerContainer> getDockerContainer(final DockerImage image, {final bool useApache = false}) async {
late ProcessResult result;
late int port;
while (true) {
@ -155,12 +155,16 @@ Future<DockerContainer> getDockerContainer(final DockerImage image) async {
'run',
'--rm',
'-d',
'--net',
'host',
'--add-host',
'host.docker.internal:host-gateway',
'-p',
'$port:80',
image,
if (!useApache) ...[
'php',
'-S',
'0.0.0.0:$port',
'0.0.0.0:80',
],
],
);
// 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());
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,
);
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 {
@ -48,13 +48,13 @@ Future run(final DockerImage image) async {
expect(response.starredCount, null);
expect(response.newestItemId, isNotNull);
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();
expect(response.starredCount, 0);
expect(response.newestItemId, isNotNull);
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 {
@ -247,7 +247,7 @@ Future run(final DockerImage image) async {
expect(response.newestItemId, isNotNull);
expect(response.feeds, hasLength(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 {

Loading…
Cancel
Save