Skip to content

Commit

Permalink
Merge pull request #1302 from nextcloud/feat/nextcloud_test/server-28
Browse files Browse the repository at this point in the history
  • Loading branch information
provokateurin authored Dec 15, 2023
2 parents 999d805 + f314317 commit 1ad7663
Show file tree
Hide file tree
Showing 16 changed files with 42 additions and 25 deletions.
2 changes: 1 addition & 1 deletion packages/nextcloud/lib/src/helpers/core.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import 'package:version/version.dart';
final minVersion = Version(26, 0, 0);

/// Maximum major of core/Server supported
const maxMajor = 27;
const maxMajor = 28;

extension CoreVersionCheck on core.Client {
/// Check if the core/Server version is supported by this client
Expand Down
2 changes: 1 addition & 1 deletion packages/nextcloud/lib/src/helpers/spreed.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import 'package:version/version.dart';
final minVersion = Version(16, 0, 0);

/// Maximum major of spreed supported
const maxMajor = 17;
const maxMajor = 18;

/// Extension for checking whether spreed is supported.
extension SpreedVersionCheck on spreed.Client {
Expand Down
2 changes: 1 addition & 1 deletion packages/nextcloud/test/fixtures/notes/delete_note.regexp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ accept: application/json
accept-encoding: gzip
content-length: 0
authorization: Basic mock
DELETE http://localhost/index\.php/apps/notes/api/v1/notes/182
DELETE http://localhost/index\.php/apps/notes/api/v1/notes/[0-9]+
user-agent: Dart/3\.2 \(dart:io\)
accept: application/json
transfer-encoding: chunked
Expand Down
2 changes: 1 addition & 1 deletion packages/nextcloud/test/fixtures/notes/get_note.regexp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ accept: application/json
transfer-encoding: chunked
accept-encoding: gzip
authorization: Basic mock
GET http://localhost/index\.php/apps/notes/api/v1/notes/182
GET http://localhost/index\.php/apps/notes/api/v1/notes/[0-9]+
user-agent: Dart/3\.2 \(dart:io\)
accept: application/json
accept-encoding: gzip
Expand Down
4 changes: 2 additions & 2 deletions packages/nextcloud/test/fixtures/notes/update_note.regexp
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ accept: application/json
transfer-encoding: chunked
accept-encoding: gzip
authorization: Basic mock
PUT http://localhost/index\.php/apps/notes/api/v1/notes/182\?title=b
PUT http://localhost/index\.php/apps/notes/api/v1/notes/[0-9]+\?title=b
user-agent: Dart/3\.2 \(dart:io\)
accept: application/json
transfer-encoding: chunked
accept-encoding: gzip
authorization: Basic mock
GET http://localhost/index\.php/apps/notes/api/v1/notes/182
GET http://localhost/index\.php/apps/notes/api/v1/notes/[0-9]+
user-agent: Dart/3\.2 \(dart:io\)
accept: application/json
accept-encoding: gzip
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ accept: application/json
transfer-encoding: chunked
accept-encoding: gzip
authorization: Basic mock
PUT http://localhost/index\.php/apps/notes/api/v1/notes/182\?title=b
PUT http://localhost/index\.php/apps/notes/api/v1/notes/[0-9]+\?title=b
user-agent: Dart/3\.2 \(dart:io\)
accept: application/json
transfer-encoding: chunked
accept-encoding: gzip
authorization: Basic mock
if-match: "[a-z0-9]{32}"
PUT http://localhost/index\.php/apps/notes/api/v1/notes/182\?title=c
PUT http://localhost/index\.php/apps/notes/api/v1/notes/[0-9]+\?title=c
user-agent: Dart/3\.2 \(dart:io\)
accept: application/json
transfer-encoding: chunked
Expand Down
2 changes: 1 addition & 1 deletion packages/nextcloud/test/spreed_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ void main() {
group('Room', () {
test('Get rooms', () async {
final response = await client1.spreed.room.getRooms();
expect(response.body.ocs.data, hasLength(1));
expect(response.body.ocs.data, isNotEmpty);
expect(response.body.ocs.data[0].id, 1);
expect(response.body.ocs.data[0].token, isNotEmpty);
expect(response.body.ocs.data[0].type, spreed.RoomType.changelog.value);
Expand Down
11 changes: 8 additions & 3 deletions packages/nextcloud_test/bin/generate_presets.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,14 @@ Future<void> main() async {
final buffer = StringBuffer()..writeln('SERVER_VERSION=$serverVersion');

for (final a in apps) {
buffer
..write(a.id.toUpperCase())
..write('_URL=');
if (a == app) {
buffer.writeln('${a.id.toUpperCase()}_URL=${release.url}');
buffer.writeln(release.url);
} else {
buffer.writeln('${a.id.toUpperCase()}_URL=${a.findLatestRelease(serverVersion).url}');
final release = a.findLatestCompatibleRelease(serverVersion) ?? a.findLatestRelease();
buffer.writeln(release.url);
}
}

Expand All @@ -53,7 +57,8 @@ Future<void> main() async {
final buffer = StringBuffer()..writeln('SERVER_VERSION=$serverVersion');

for (final app in apps) {
buffer.writeln('${app.id.toUpperCase()}_URL=${app.findLatestRelease(serverVersion).url}');
final release = app.findLatestCompatibleRelease(serverVersion) ?? app.findLatestRelease();
buffer.writeln('${app.id.toUpperCase()}_URL=${release.url}');
}

File('${serverPresetsDir.path}/${serverVersion.withoutPatch()}').writeAsStringSync(buffer.toString());
Expand Down
2 changes: 1 addition & 1 deletion packages/nextcloud_test/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ RUN curl -L "$SPREED_URL" | tar -xz -C /
FROM nextcloud

COPY --from=news /news /usr/src/nextcloud/apps/news
RUN ./occ app:enable news
RUN ./occ app:enable news --force # TODO remove once news supports server 28

COPY --from=notes /notes /usr/src/nextcloud/apps/notes
RUN ./occ app:enable notes
Expand Down
2 changes: 1 addition & 1 deletion packages/nextcloud_test/docker/presets/latest
4 changes: 2 additions & 2 deletions packages/nextcloud_test/docker/presets/notes/4.8
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
SERVER_VERSION=27.1.4
SERVER_VERSION=28.0.0
NEWS_URL=https://github.com/nextcloud/news/releases/download/24.0.0/news.tar.gz
NOTES_URL=https://github.com/nextcloud-releases/notes/releases/download/v4.8.1/notes.tar.gz
SPREED_URL=https://github.com/nextcloud-releases/spreed/releases/download/v17.1.3/spreed-v17.1.3.tar.gz
SPREED_URL=https://github.com/nextcloud-releases/spreed/releases/download/v18.0.0/spreed-v18.0.0.tar.gz
UPPUSH_URL=https://codeberg.org/NextPush/uppush/archive/1.4.1.tar.gz
4 changes: 2 additions & 2 deletions packages/nextcloud_test/docker/presets/notes/4.9
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
SERVER_VERSION=27.1.4
SERVER_VERSION=28.0.0
NEWS_URL=https://github.com/nextcloud/news/releases/download/24.0.0/news.tar.gz
NOTES_URL=https://github.com/nextcloud-releases/notes/releases/download/v4.9.0/notes-v4.9.0.tar.gz
SPREED_URL=https://github.com/nextcloud-releases/spreed/releases/download/v17.1.3/spreed-v17.1.3.tar.gz
SPREED_URL=https://github.com/nextcloud-releases/spreed/releases/download/v18.0.0/spreed-v18.0.0.tar.gz
UPPUSH_URL=https://codeberg.org/NextPush/uppush/archive/1.4.1.tar.gz
5 changes: 5 additions & 0 deletions packages/nextcloud_test/docker/presets/server/28.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
SERVER_VERSION=28.0.0
NEWS_URL=https://github.com/nextcloud/news/releases/download/24.0.0/news.tar.gz
NOTES_URL=https://github.com/nextcloud-releases/notes/releases/download/v4.9.0/notes-v4.9.0.tar.gz
SPREED_URL=https://github.com/nextcloud-releases/spreed/releases/download/v18.0.0/spreed-v18.0.0.tar.gz
UPPUSH_URL=https://codeberg.org/NextPush/uppush/archive/1.4.1.tar.gz
5 changes: 5 additions & 0 deletions packages/nextcloud_test/docker/presets/spreed/18.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
SERVER_VERSION=28.0.0
NEWS_URL=https://github.com/nextcloud/news/releases/download/24.0.0/news.tar.gz
NOTES_URL=https://github.com/nextcloud-releases/notes/releases/download/v4.9.0/notes-v4.9.0.tar.gz
SPREED_URL=https://github.com/nextcloud-releases/spreed/releases/download/v18.0.0/spreed-v18.0.0.tar.gz
UPPUSH_URL=https://codeberg.org/NextPush/uppush/archive/1.4.1.tar.gz
4 changes: 2 additions & 2 deletions packages/nextcloud_test/docker/presets/uppush/1.4
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
SERVER_VERSION=27.1.4
SERVER_VERSION=28.0.0
NEWS_URL=https://github.com/nextcloud/news/releases/download/24.0.0/news.tar.gz
NOTES_URL=https://github.com/nextcloud-releases/notes/releases/download/v4.9.0/notes-v4.9.0.tar.gz
SPREED_URL=https://github.com/nextcloud-releases/spreed/releases/download/v17.1.3/spreed-v17.1.3.tar.gz
SPREED_URL=https://github.com/nextcloud-releases/spreed/releases/download/v18.0.0/spreed-v18.0.0.tar.gz
UPPUSH_URL=https://codeberg.org/NextPush/uppush/archive/1.4.1.tar.gz
12 changes: 7 additions & 5 deletions packages/nextcloud_test/lib/src/app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,20 @@ typedef App = ({

@internal
extension AppFindLatestRelease on App {
AppRelease findLatestRelease(final ExtendedVersion serverVersion) {
AppRelease? findLatestCompatibleRelease(final ExtendedVersion serverVersion) {
final compatibleReleases = releases
.where(
(final release) =>
serverVersion >= release.minimumServerVersion && serverVersion <= release.maximumServerVersion,
)
.toList()
..sort((final a, final b) => b.version.compareTo(a.version));
if (compatibleReleases.isEmpty) {
throw Exception('App $id has no compatible release with server $serverVersion.');
}
return compatibleReleases.first;
return compatibleReleases.firstOrNull;
}

AppRelease findLatestRelease() {
final sortedReleases = releases..sort((final a, final b) => b.version.compareTo(a.version));
return sortedReleases.first;
}
}

Expand Down

0 comments on commit 1ad7663

Please sign in to comment.