2021-09-25 18:22:19 +02:00
|
|
|
import 'package:intl/intl.dart';
|
2021-11-12 22:13:02 +01:00
|
|
|
import 'package:nc_photos/ci_string.dart';
|
2021-04-15 20:46:34 +02:00
|
|
|
import 'package:nc_photos/entity/album.dart';
|
2021-06-26 13:51:13 +02:00
|
|
|
import 'package:nc_photos/entity/album/cover_provider.dart';
|
2021-07-05 09:54:01 +02:00
|
|
|
import 'package:nc_photos/entity/album/item.dart';
|
2021-06-24 18:26:56 +02:00
|
|
|
import 'package:nc_photos/entity/album/provider.dart';
|
2021-07-07 20:40:43 +02:00
|
|
|
import 'package:nc_photos/entity/album/sort_provider.dart';
|
2021-06-24 16:54:41 +02:00
|
|
|
import 'package:nc_photos/entity/album/upgrader.dart';
|
2021-04-15 20:46:34 +02:00
|
|
|
import 'package:nc_photos/entity/file.dart';
|
2021-11-11 18:03:36 +01:00
|
|
|
import 'package:nc_photos/type.dart';
|
2021-04-15 20:46:34 +02:00
|
|
|
import 'package:test/test.dart';
|
|
|
|
|
2021-11-12 22:13:02 +01:00
|
|
|
import '../test_util.dart' as test_util;
|
|
|
|
|
2021-04-15 20:46:34 +02:00
|
|
|
void main() {
|
|
|
|
group("Album", () {
|
|
|
|
group("fromJson", () {
|
|
|
|
test("lastUpdated", () {
|
|
|
|
final json = <String, dynamic>{
|
|
|
|
"version": Album.version,
|
|
|
|
"lastUpdated": "2020-01-02T03:04:05.678901Z",
|
2021-07-23 22:05:57 +02:00
|
|
|
"name": "",
|
2021-06-24 18:26:56 +02:00
|
|
|
"provider": <String, dynamic>{
|
|
|
|
"type": "static",
|
|
|
|
"content": <String, dynamic>{
|
|
|
|
"items": [],
|
|
|
|
},
|
|
|
|
},
|
2021-06-26 13:51:13 +02:00
|
|
|
"coverProvider": <String, dynamic>{
|
|
|
|
"type": "auto",
|
|
|
|
"content": <String, dynamic>{},
|
|
|
|
},
|
2021-07-07 20:40:43 +02:00
|
|
|
"sortProvider": <String, dynamic>{
|
|
|
|
"type": "null",
|
|
|
|
"content": <String, dynamic>{},
|
|
|
|
},
|
2021-04-15 20:46:34 +02:00
|
|
|
};
|
|
|
|
expect(
|
2021-09-25 18:22:19 +02:00
|
|
|
Album.fromJson(
|
|
|
|
json,
|
2021-11-18 09:43:14 +01:00
|
|
|
upgraderFactory: const _NullAlbumUpgraderFactory(),
|
2021-09-25 18:22:19 +02:00
|
|
|
),
|
2021-04-15 20:46:34 +02:00
|
|
|
Album(
|
|
|
|
lastUpdated: DateTime.utc(2020, 1, 2, 3, 4, 5, 678, 901),
|
|
|
|
name: "",
|
2021-06-24 18:26:56 +02:00
|
|
|
provider: AlbumStaticProvider(
|
|
|
|
items: [],
|
|
|
|
),
|
2021-06-26 13:51:13 +02:00
|
|
|
coverProvider: AlbumAutoCoverProvider(),
|
2021-09-15 08:58:06 +02:00
|
|
|
sortProvider: const AlbumNullSortProvider(),
|
2021-04-15 20:46:34 +02:00
|
|
|
));
|
|
|
|
});
|
|
|
|
|
|
|
|
test("name", () {
|
|
|
|
final json = <String, dynamic>{
|
|
|
|
"version": Album.version,
|
|
|
|
"lastUpdated": "2020-01-02T03:04:05.678901Z",
|
|
|
|
"name": "album",
|
2021-06-24 18:26:56 +02:00
|
|
|
"provider": <String, dynamic>{
|
|
|
|
"type": "static",
|
|
|
|
"content": <String, dynamic>{
|
|
|
|
"items": [],
|
|
|
|
},
|
|
|
|
},
|
2021-06-26 13:51:13 +02:00
|
|
|
"coverProvider": <String, dynamic>{
|
|
|
|
"type": "auto",
|
|
|
|
"content": <String, dynamic>{},
|
|
|
|
},
|
2021-07-07 20:40:43 +02:00
|
|
|
"sortProvider": <String, dynamic>{
|
|
|
|
"type": "null",
|
|
|
|
"content": <String, dynamic>{},
|
|
|
|
},
|
2021-04-15 20:46:34 +02:00
|
|
|
};
|
|
|
|
expect(
|
2021-09-25 18:22:19 +02:00
|
|
|
Album.fromJson(
|
|
|
|
json,
|
2021-11-18 09:43:14 +01:00
|
|
|
upgraderFactory: const _NullAlbumUpgraderFactory(),
|
2021-09-25 18:22:19 +02:00
|
|
|
),
|
2021-04-15 20:46:34 +02:00
|
|
|
Album(
|
|
|
|
lastUpdated: DateTime.utc(2020, 1, 2, 3, 4, 5, 678, 901),
|
|
|
|
name: "album",
|
2021-06-24 18:26:56 +02:00
|
|
|
provider: AlbumStaticProvider(
|
|
|
|
items: [],
|
|
|
|
),
|
2021-06-26 13:51:13 +02:00
|
|
|
coverProvider: AlbumAutoCoverProvider(),
|
2021-09-15 08:58:06 +02:00
|
|
|
sortProvider: const AlbumNullSortProvider(),
|
2021-04-15 20:46:34 +02:00
|
|
|
));
|
|
|
|
});
|
|
|
|
|
2021-07-09 12:07:37 +02:00
|
|
|
group("AlbumStaticProvider", () {
|
|
|
|
test("AlbumFileItem", () {
|
|
|
|
final json = <String, dynamic>{
|
|
|
|
"version": Album.version,
|
|
|
|
"lastUpdated": "2020-01-02T03:04:05.678901Z",
|
|
|
|
"name": "",
|
|
|
|
"provider": <String, dynamic>{
|
|
|
|
"type": "static",
|
|
|
|
"content": <String, dynamic>{
|
|
|
|
"items": [
|
|
|
|
<String, dynamic>{
|
|
|
|
"type": "file",
|
|
|
|
"content": <String, dynamic>{
|
|
|
|
"file": <String, dynamic>{
|
|
|
|
"path": "remote.php/dav/files/admin/test1.jpg",
|
|
|
|
},
|
2021-06-24 18:26:56 +02:00
|
|
|
},
|
2021-10-23 20:13:06 +02:00
|
|
|
"addedBy": "admin",
|
|
|
|
"addedAt": "2020-01-02T03:04:05.678901Z",
|
2021-06-24 18:26:56 +02:00
|
|
|
},
|
2021-07-09 12:07:37 +02:00
|
|
|
<String, dynamic>{
|
|
|
|
"type": "file",
|
|
|
|
"content": <String, dynamic>{
|
|
|
|
"file": <String, dynamic>{
|
|
|
|
"path": "remote.php/dav/files/admin/test2.jpg",
|
|
|
|
},
|
2021-06-24 18:26:56 +02:00
|
|
|
},
|
2021-10-23 20:13:06 +02:00
|
|
|
"addedBy": "admin",
|
|
|
|
"addedAt": "2020-01-02T03:04:05.678901Z",
|
2021-06-24 18:26:56 +02:00
|
|
|
},
|
2021-07-09 12:07:37 +02:00
|
|
|
],
|
|
|
|
},
|
2021-04-15 20:46:34 +02:00
|
|
|
},
|
2021-07-09 12:07:37 +02:00
|
|
|
"coverProvider": <String, dynamic>{
|
|
|
|
"type": "auto",
|
|
|
|
"content": <String, dynamic>{},
|
|
|
|
},
|
|
|
|
"sortProvider": <String, dynamic>{
|
|
|
|
"type": "null",
|
|
|
|
"content": <String, dynamic>{},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
expect(
|
2021-09-25 18:22:19 +02:00
|
|
|
Album.fromJson(
|
|
|
|
json,
|
2021-11-18 09:43:14 +01:00
|
|
|
upgraderFactory: const _NullAlbumUpgraderFactory(),
|
2021-09-25 18:22:19 +02:00
|
|
|
),
|
2021-07-09 12:07:37 +02:00
|
|
|
Album(
|
|
|
|
lastUpdated: DateTime.utc(2020, 1, 2, 3, 4, 5, 678, 901),
|
|
|
|
name: "",
|
|
|
|
provider: AlbumStaticProvider(
|
|
|
|
items: [
|
|
|
|
AlbumFileItem(
|
2021-11-12 22:13:02 +01:00
|
|
|
addedBy: "admin".toCi(),
|
2021-10-23 20:13:06 +02:00
|
|
|
addedAt: DateTime.utc(2020, 1, 2, 3, 4, 5, 678, 901),
|
2021-07-09 12:07:37 +02:00
|
|
|
file: File(path: "remote.php/dav/files/admin/test1.jpg"),
|
|
|
|
),
|
|
|
|
AlbumFileItem(
|
2021-11-12 22:13:02 +01:00
|
|
|
addedBy: "admin".toCi(),
|
2021-10-23 20:13:06 +02:00
|
|
|
addedAt: DateTime.utc(2020, 1, 2, 3, 4, 5, 678, 901),
|
2021-07-09 12:07:37 +02:00
|
|
|
file: File(path: "remote.php/dav/files/admin/test2.jpg"),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
coverProvider: AlbumAutoCoverProvider(),
|
2021-09-15 08:58:06 +02:00
|
|
|
sortProvider: const AlbumNullSortProvider(),
|
2021-07-09 12:07:37 +02:00
|
|
|
));
|
|
|
|
});
|
|
|
|
|
|
|
|
test("AlbumLabelItem", () {
|
|
|
|
final json = <String, dynamic>{
|
|
|
|
"version": Album.version,
|
|
|
|
"lastUpdated": "2020-01-02T03:04:05.678901Z",
|
|
|
|
"name": "",
|
|
|
|
"provider": <String, dynamic>{
|
|
|
|
"type": "static",
|
|
|
|
"content": <String, dynamic>{
|
|
|
|
"items": [
|
|
|
|
<String, dynamic>{
|
|
|
|
"type": "label",
|
|
|
|
"content": <String, dynamic>{
|
|
|
|
"text": "Testing",
|
|
|
|
},
|
2021-10-23 20:13:06 +02:00
|
|
|
"addedBy": "admin",
|
|
|
|
"addedAt": "2020-01-02T03:04:05.678901Z",
|
2021-07-09 12:07:37 +02:00
|
|
|
},
|
2021-06-24 18:26:56 +02:00
|
|
|
],
|
2021-07-09 12:07:37 +02:00
|
|
|
},
|
|
|
|
},
|
|
|
|
"coverProvider": <String, dynamic>{
|
|
|
|
"type": "auto",
|
|
|
|
"content": <String, dynamic>{},
|
|
|
|
},
|
|
|
|
"sortProvider": <String, dynamic>{
|
|
|
|
"type": "null",
|
|
|
|
"content": <String, dynamic>{},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
expect(
|
2021-09-25 18:22:19 +02:00
|
|
|
Album.fromJson(
|
|
|
|
json,
|
2021-11-18 09:43:14 +01:00
|
|
|
upgraderFactory: const _NullAlbumUpgraderFactory(),
|
2021-09-25 18:22:19 +02:00
|
|
|
),
|
2021-07-09 12:07:37 +02:00
|
|
|
Album(
|
|
|
|
lastUpdated: DateTime.utc(2020, 1, 2, 3, 4, 5, 678, 901),
|
|
|
|
name: "",
|
|
|
|
provider: AlbumStaticProvider(
|
|
|
|
items: [
|
|
|
|
AlbumLabelItem(
|
2021-11-12 22:13:02 +01:00
|
|
|
addedBy: "admin".toCi(),
|
2021-10-23 20:13:06 +02:00
|
|
|
addedAt: DateTime.utc(2020, 1, 2, 3, 4, 5, 678, 901),
|
2021-07-09 12:07:37 +02:00
|
|
|
text: "Testing",
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
coverProvider: AlbumAutoCoverProvider(),
|
2021-09-15 08:58:06 +02:00
|
|
|
sortProvider: const AlbumNullSortProvider(),
|
2021-07-09 12:07:37 +02:00
|
|
|
));
|
|
|
|
});
|
2021-06-26 13:51:13 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
test("AlbumAutoCoverProvider", () {
|
|
|
|
final json = <String, dynamic>{
|
|
|
|
"version": Album.version,
|
|
|
|
"lastUpdated": "2020-01-02T03:04:05.678901Z",
|
|
|
|
"name": "",
|
|
|
|
"provider": <String, dynamic>{
|
|
|
|
"type": "static",
|
|
|
|
"content": <String, dynamic>{
|
|
|
|
"items": [],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"coverProvider": <String, dynamic>{
|
|
|
|
"type": "auto",
|
|
|
|
"content": <String, dynamic>{
|
|
|
|
"coverFile": <String, dynamic>{
|
|
|
|
"path": "remote.php/dav/files/admin/test1.jpg",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-07-07 20:40:43 +02:00
|
|
|
"sortProvider": <String, dynamic>{
|
|
|
|
"type": "null",
|
|
|
|
"content": <String, dynamic>{},
|
|
|
|
},
|
2021-06-26 13:51:13 +02:00
|
|
|
};
|
|
|
|
expect(
|
2021-09-25 18:22:19 +02:00
|
|
|
Album.fromJson(
|
|
|
|
json,
|
2021-11-18 09:43:14 +01:00
|
|
|
upgraderFactory: const _NullAlbumUpgraderFactory(),
|
2021-09-25 18:22:19 +02:00
|
|
|
),
|
2021-06-26 13:51:13 +02:00
|
|
|
Album(
|
|
|
|
lastUpdated: DateTime.utc(2020, 1, 2, 3, 4, 5, 678, 901),
|
|
|
|
name: "",
|
|
|
|
provider: AlbumStaticProvider(
|
|
|
|
items: [],
|
|
|
|
),
|
|
|
|
coverProvider: AlbumAutoCoverProvider(
|
|
|
|
coverFile: File(
|
|
|
|
path: "remote.php/dav/files/admin/test1.jpg",
|
|
|
|
),
|
|
|
|
),
|
2021-09-15 08:58:06 +02:00
|
|
|
sortProvider: const AlbumNullSortProvider(),
|
2021-07-07 20:40:43 +02:00
|
|
|
));
|
|
|
|
});
|
|
|
|
|
|
|
|
test("AlbumTimeSortProvider", () {
|
|
|
|
final json = <String, dynamic>{
|
|
|
|
"version": Album.version,
|
|
|
|
"lastUpdated": "2020-01-02T03:04:05.678901Z",
|
|
|
|
"name": "",
|
|
|
|
"provider": <String, dynamic>{
|
|
|
|
"type": "static",
|
|
|
|
"content": <String, dynamic>{
|
|
|
|
"items": [],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"coverProvider": <String, dynamic>{
|
|
|
|
"type": "auto",
|
|
|
|
"content": <String, dynamic>{},
|
|
|
|
},
|
|
|
|
"sortProvider": <String, dynamic>{
|
|
|
|
"type": "time",
|
|
|
|
"content": <String, dynamic>{
|
|
|
|
"isAscending": true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
expect(
|
2021-09-25 18:22:19 +02:00
|
|
|
Album.fromJson(
|
|
|
|
json,
|
2021-11-18 09:43:14 +01:00
|
|
|
upgraderFactory: const _NullAlbumUpgraderFactory(),
|
2021-09-25 18:22:19 +02:00
|
|
|
),
|
2021-07-07 20:40:43 +02:00
|
|
|
Album(
|
|
|
|
lastUpdated: DateTime.utc(2020, 1, 2, 3, 4, 5, 678, 901),
|
|
|
|
name: "",
|
|
|
|
provider: AlbumStaticProvider(
|
|
|
|
items: [],
|
|
|
|
),
|
|
|
|
coverProvider: AlbumAutoCoverProvider(),
|
2021-09-15 08:58:06 +02:00
|
|
|
sortProvider: const AlbumTimeSortProvider(
|
2021-07-07 20:40:43 +02:00
|
|
|
isAscending: true,
|
|
|
|
),
|
2021-04-15 20:46:34 +02:00
|
|
|
));
|
|
|
|
});
|
|
|
|
|
2021-11-11 18:03:36 +01:00
|
|
|
test("shares", _fromJsonShares);
|
|
|
|
|
2021-04-15 20:46:34 +02:00
|
|
|
test("albumFile", () {
|
|
|
|
final json = <String, dynamic>{
|
|
|
|
"version": Album.version,
|
|
|
|
"lastUpdated": "2020-01-02T03:04:05.678901Z",
|
2021-07-23 22:05:57 +02:00
|
|
|
"name": "",
|
2021-06-24 18:26:56 +02:00
|
|
|
"provider": <String, dynamic>{
|
|
|
|
"type": "static",
|
|
|
|
"content": <String, dynamic>{
|
|
|
|
"items": [],
|
|
|
|
},
|
|
|
|
},
|
2021-06-26 13:51:13 +02:00
|
|
|
"coverProvider": <String, dynamic>{
|
|
|
|
"type": "auto",
|
|
|
|
"content": <String, dynamic>{},
|
|
|
|
},
|
2021-07-07 20:40:43 +02:00
|
|
|
"sortProvider": <String, dynamic>{
|
|
|
|
"type": "null",
|
|
|
|
"content": <String, dynamic>{},
|
|
|
|
},
|
2021-04-15 20:46:34 +02:00
|
|
|
"albumFile": <String, dynamic>{
|
2021-05-25 21:55:25 +02:00
|
|
|
"path": "remote.php/dav/files/admin/test1.jpg",
|
2021-04-15 20:46:34 +02:00
|
|
|
},
|
|
|
|
};
|
|
|
|
expect(
|
2021-09-25 18:22:19 +02:00
|
|
|
Album.fromJson(
|
|
|
|
json,
|
2021-11-18 09:43:14 +01:00
|
|
|
upgraderFactory: const _NullAlbumUpgraderFactory(),
|
2021-09-25 18:22:19 +02:00
|
|
|
),
|
2021-04-15 20:46:34 +02:00
|
|
|
Album(
|
|
|
|
lastUpdated: DateTime.utc(2020, 1, 2, 3, 4, 5, 678, 901),
|
|
|
|
name: "",
|
2021-06-24 18:26:56 +02:00
|
|
|
provider: AlbumStaticProvider(
|
|
|
|
items: [],
|
|
|
|
),
|
2021-06-26 13:51:13 +02:00
|
|
|
coverProvider: AlbumAutoCoverProvider(),
|
2021-09-15 08:58:06 +02:00
|
|
|
sortProvider: const AlbumNullSortProvider(),
|
2021-05-25 21:55:25 +02:00
|
|
|
albumFile: File(path: "remote.php/dav/files/admin/test1.jpg"),
|
2021-04-15 20:46:34 +02:00
|
|
|
));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
group("toRemoteJson", () {
|
|
|
|
test("lastUpdated", () {
|
|
|
|
final album = Album(
|
|
|
|
lastUpdated: DateTime.utc(2020, 1, 2, 3, 4, 5, 678, 901),
|
|
|
|
name: "",
|
2021-06-24 18:26:56 +02:00
|
|
|
provider: AlbumStaticProvider(
|
|
|
|
items: [],
|
|
|
|
),
|
2021-06-26 13:51:13 +02:00
|
|
|
coverProvider: AlbumAutoCoverProvider(),
|
2021-09-15 08:58:06 +02:00
|
|
|
sortProvider: const AlbumNullSortProvider(),
|
2021-04-15 20:46:34 +02:00
|
|
|
);
|
|
|
|
expect(album.toRemoteJson(), <String, dynamic>{
|
|
|
|
"version": Album.version,
|
|
|
|
"lastUpdated": "2020-01-02T03:04:05.678901Z",
|
|
|
|
"name": "",
|
2021-06-24 18:26:56 +02:00
|
|
|
"provider": <String, dynamic>{
|
|
|
|
"type": "static",
|
|
|
|
"content": <String, dynamic>{
|
|
|
|
"items": [],
|
|
|
|
},
|
|
|
|
},
|
2021-06-26 13:51:13 +02:00
|
|
|
"coverProvider": <String, dynamic>{
|
|
|
|
"type": "auto",
|
|
|
|
"content": <String, dynamic>{},
|
|
|
|
},
|
2021-07-07 20:40:43 +02:00
|
|
|
"sortProvider": <String, dynamic>{
|
|
|
|
"type": "null",
|
|
|
|
"content": <String, dynamic>{},
|
|
|
|
},
|
2021-04-15 20:46:34 +02:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
test("name", () {
|
|
|
|
final album = Album(
|
|
|
|
lastUpdated: DateTime.utc(2020, 1, 2, 3, 4, 5, 678, 901),
|
|
|
|
name: "album",
|
2021-06-24 18:26:56 +02:00
|
|
|
provider: AlbumStaticProvider(
|
|
|
|
items: [],
|
|
|
|
),
|
2021-06-26 13:51:13 +02:00
|
|
|
coverProvider: AlbumAutoCoverProvider(),
|
2021-09-15 08:58:06 +02:00
|
|
|
sortProvider: const AlbumNullSortProvider(),
|
2021-04-15 20:46:34 +02:00
|
|
|
);
|
|
|
|
expect(album.toRemoteJson(), <String, dynamic>{
|
|
|
|
"version": Album.version,
|
|
|
|
"lastUpdated": "2020-01-02T03:04:05.678901Z",
|
|
|
|
"name": "album",
|
2021-06-24 18:26:56 +02:00
|
|
|
"provider": <String, dynamic>{
|
|
|
|
"type": "static",
|
|
|
|
"content": <String, dynamic>{
|
|
|
|
"items": [],
|
|
|
|
},
|
|
|
|
},
|
2021-06-26 13:51:13 +02:00
|
|
|
"coverProvider": <String, dynamic>{
|
|
|
|
"type": "auto",
|
|
|
|
"content": <String, dynamic>{},
|
|
|
|
},
|
2021-07-07 20:40:43 +02:00
|
|
|
"sortProvider": <String, dynamic>{
|
|
|
|
"type": "null",
|
|
|
|
"content": <String, dynamic>{},
|
|
|
|
},
|
2021-04-15 20:46:34 +02:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2021-07-09 12:07:37 +02:00
|
|
|
group("AlbumStaticProvider", () {
|
|
|
|
test("AlbumFileItem", () {
|
|
|
|
final album = Album(
|
|
|
|
lastUpdated: DateTime.utc(2020, 1, 2, 3, 4, 5, 678, 901),
|
|
|
|
name: "",
|
|
|
|
provider: AlbumStaticProvider(
|
|
|
|
items: [
|
|
|
|
AlbumFileItem(
|
2021-11-12 22:13:02 +01:00
|
|
|
addedBy: "admin".toCi(),
|
2021-10-23 20:13:06 +02:00
|
|
|
addedAt: DateTime.utc(2020, 1, 2, 3, 4, 5, 678, 901),
|
2021-07-09 12:07:37 +02:00
|
|
|
file: File(path: "remote.php/dav/files/admin/test1.jpg"),
|
|
|
|
),
|
|
|
|
AlbumFileItem(
|
2021-11-12 22:13:02 +01:00
|
|
|
addedBy: "admin".toCi(),
|
2021-10-23 20:13:06 +02:00
|
|
|
addedAt: DateTime.utc(2020, 1, 2, 3, 4, 5, 678, 901),
|
2021-07-09 12:07:37 +02:00
|
|
|
file: File(path: "remote.php/dav/files/admin/test2.jpg"),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
coverProvider: AlbumAutoCoverProvider(),
|
2021-09-15 08:58:06 +02:00
|
|
|
sortProvider: const AlbumNullSortProvider(),
|
2021-07-09 12:07:37 +02:00
|
|
|
);
|
|
|
|
expect(album.toRemoteJson(), <String, dynamic>{
|
|
|
|
"version": Album.version,
|
|
|
|
"lastUpdated": "2020-01-02T03:04:05.678901Z",
|
|
|
|
"name": "",
|
|
|
|
"provider": <String, dynamic>{
|
|
|
|
"type": "static",
|
|
|
|
"content": <String, dynamic>{
|
|
|
|
"items": [
|
|
|
|
<String, dynamic>{
|
|
|
|
"type": "file",
|
|
|
|
"content": <String, dynamic>{
|
|
|
|
"file": <String, dynamic>{
|
|
|
|
"path": "remote.php/dav/files/admin/test1.jpg",
|
|
|
|
},
|
2021-06-24 18:26:56 +02:00
|
|
|
},
|
2021-10-23 20:13:06 +02:00
|
|
|
"addedBy": "admin",
|
|
|
|
"addedAt": "2020-01-02T03:04:05.678901Z",
|
2021-06-24 18:26:56 +02:00
|
|
|
},
|
2021-07-09 12:07:37 +02:00
|
|
|
<String, dynamic>{
|
|
|
|
"type": "file",
|
|
|
|
"content": <String, dynamic>{
|
|
|
|
"file": <String, dynamic>{
|
|
|
|
"path": "remote.php/dav/files/admin/test2.jpg",
|
|
|
|
},
|
2021-06-24 18:26:56 +02:00
|
|
|
},
|
2021-10-23 20:13:06 +02:00
|
|
|
"addedBy": "admin",
|
|
|
|
"addedAt": "2020-01-02T03:04:05.678901Z",
|
2021-06-24 18:26:56 +02:00
|
|
|
},
|
2021-07-09 12:07:37 +02:00
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"coverProvider": <String, dynamic>{
|
|
|
|
"type": "auto",
|
|
|
|
"content": <String, dynamic>{},
|
|
|
|
},
|
|
|
|
"sortProvider": <String, dynamic>{
|
|
|
|
"type": "null",
|
|
|
|
"content": <String, dynamic>{},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
test("AlbumLabelItem", () {
|
|
|
|
final album = Album(
|
|
|
|
lastUpdated: DateTime.utc(2020, 1, 2, 3, 4, 5, 678, 901),
|
|
|
|
name: "",
|
|
|
|
provider: AlbumStaticProvider(
|
|
|
|
items: [
|
|
|
|
AlbumLabelItem(
|
2021-11-12 22:13:02 +01:00
|
|
|
addedBy: "admin".toCi(),
|
2021-10-23 20:13:06 +02:00
|
|
|
addedAt: DateTime.utc(2020, 1, 2, 3, 4, 5, 678, 901),
|
2021-07-09 12:07:37 +02:00
|
|
|
text: "Testing",
|
|
|
|
),
|
2021-06-24 18:26:56 +02:00
|
|
|
],
|
2021-07-09 12:07:37 +02:00
|
|
|
),
|
|
|
|
coverProvider: AlbumAutoCoverProvider(),
|
2021-09-15 08:58:06 +02:00
|
|
|
sortProvider: const AlbumNullSortProvider(),
|
2021-07-09 12:07:37 +02:00
|
|
|
);
|
|
|
|
expect(album.toRemoteJson(), <String, dynamic>{
|
|
|
|
"version": Album.version,
|
|
|
|
"lastUpdated": "2020-01-02T03:04:05.678901Z",
|
|
|
|
"name": "",
|
|
|
|
"provider": <String, dynamic>{
|
|
|
|
"type": "static",
|
|
|
|
"content": <String, dynamic>{
|
|
|
|
"items": [
|
|
|
|
<String, dynamic>{
|
|
|
|
"type": "label",
|
|
|
|
"content": <String, dynamic>{
|
|
|
|
"text": "Testing",
|
|
|
|
},
|
2021-10-23 20:13:06 +02:00
|
|
|
"addedBy": "admin",
|
|
|
|
"addedAt": "2020-01-02T03:04:05.678901Z",
|
2021-07-09 12:07:37 +02:00
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
2021-04-15 20:46:34 +02:00
|
|
|
},
|
2021-07-09 12:07:37 +02:00
|
|
|
"coverProvider": <String, dynamic>{
|
|
|
|
"type": "auto",
|
|
|
|
"content": <String, dynamic>{},
|
|
|
|
},
|
|
|
|
"sortProvider": <String, dynamic>{
|
|
|
|
"type": "null",
|
|
|
|
"content": <String, dynamic>{},
|
|
|
|
},
|
|
|
|
});
|
2021-06-26 13:51:13 +02:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
test("AlbumAutoCoverProvider", () {
|
|
|
|
final album = Album(
|
|
|
|
lastUpdated: DateTime.utc(2020, 1, 2, 3, 4, 5, 678, 901),
|
|
|
|
name: "",
|
|
|
|
provider: AlbumStaticProvider(
|
|
|
|
items: [],
|
|
|
|
),
|
|
|
|
coverProvider: AlbumAutoCoverProvider(
|
|
|
|
coverFile: File(path: "remote.php/dav/files/admin/test1.jpg")),
|
2021-09-15 08:58:06 +02:00
|
|
|
sortProvider: const AlbumNullSortProvider(),
|
2021-06-26 13:51:13 +02:00
|
|
|
);
|
|
|
|
expect(album.toRemoteJson(), <String, dynamic>{
|
|
|
|
"version": Album.version,
|
|
|
|
"lastUpdated": "2020-01-02T03:04:05.678901Z",
|
|
|
|
"name": "",
|
|
|
|
"provider": <String, dynamic>{
|
|
|
|
"type": "static",
|
|
|
|
"content": <String, dynamic>{
|
|
|
|
"items": [],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"coverProvider": <String, dynamic>{
|
|
|
|
"type": "auto",
|
|
|
|
"content": <String, dynamic>{
|
|
|
|
"coverFile": <String, dynamic>{
|
|
|
|
"path": "remote.php/dav/files/admin/test1.jpg",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-07-07 20:40:43 +02:00
|
|
|
"sortProvider": <String, dynamic>{
|
|
|
|
"type": "null",
|
|
|
|
"content": <String, dynamic>{},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
test("AlbumTimeSortProvider", () {
|
|
|
|
final album = Album(
|
|
|
|
lastUpdated: DateTime.utc(2020, 1, 2, 3, 4, 5, 678, 901),
|
|
|
|
name: "",
|
|
|
|
provider: AlbumStaticProvider(
|
|
|
|
items: [],
|
|
|
|
),
|
|
|
|
coverProvider: AlbumAutoCoverProvider(),
|
2021-09-15 08:58:06 +02:00
|
|
|
sortProvider: const AlbumTimeSortProvider(
|
2021-07-07 20:40:43 +02:00
|
|
|
isAscending: true,
|
|
|
|
),
|
|
|
|
);
|
|
|
|
expect(album.toAppDbJson(), <String, dynamic>{
|
|
|
|
"version": Album.version,
|
|
|
|
"lastUpdated": "2020-01-02T03:04:05.678901Z",
|
|
|
|
"name": "",
|
|
|
|
"provider": <String, dynamic>{
|
|
|
|
"type": "static",
|
|
|
|
"content": <String, dynamic>{
|
|
|
|
"items": [],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"coverProvider": <String, dynamic>{
|
|
|
|
"type": "auto",
|
|
|
|
"content": <String, dynamic>{},
|
|
|
|
},
|
|
|
|
"sortProvider": <String, dynamic>{
|
|
|
|
"type": "time",
|
|
|
|
"content": <String, dynamic>{
|
|
|
|
"isAscending": true,
|
|
|
|
},
|
|
|
|
},
|
2021-04-15 20:46:34 +02:00
|
|
|
});
|
|
|
|
});
|
2021-11-11 18:03:36 +01:00
|
|
|
|
|
|
|
test("shares", _toRemoteJsonShares);
|
2021-04-15 20:46:34 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
group("toAppDbJson", () {
|
|
|
|
test("lastUpdated", () {
|
|
|
|
final album = Album(
|
|
|
|
lastUpdated: DateTime.utc(2020, 1, 2, 3, 4, 5, 678, 901),
|
|
|
|
name: "",
|
2021-06-24 18:26:56 +02:00
|
|
|
provider: AlbumStaticProvider(
|
|
|
|
items: [],
|
|
|
|
),
|
2021-06-26 13:51:13 +02:00
|
|
|
coverProvider: AlbumAutoCoverProvider(),
|
2021-09-15 08:58:06 +02:00
|
|
|
sortProvider: const AlbumNullSortProvider(),
|
2021-04-15 20:46:34 +02:00
|
|
|
);
|
|
|
|
expect(album.toAppDbJson(), <String, dynamic>{
|
|
|
|
"version": Album.version,
|
|
|
|
"lastUpdated": "2020-01-02T03:04:05.678901Z",
|
|
|
|
"name": "",
|
2021-06-24 18:26:56 +02:00
|
|
|
"provider": <String, dynamic>{
|
|
|
|
"type": "static",
|
|
|
|
"content": <String, dynamic>{
|
|
|
|
"items": [],
|
|
|
|
},
|
|
|
|
},
|
2021-06-26 13:51:13 +02:00
|
|
|
"coverProvider": <String, dynamic>{
|
|
|
|
"type": "auto",
|
|
|
|
"content": <String, dynamic>{},
|
|
|
|
},
|
2021-07-07 20:40:43 +02:00
|
|
|
"sortProvider": <String, dynamic>{
|
|
|
|
"type": "null",
|
|
|
|
"content": <String, dynamic>{},
|
|
|
|
},
|
2021-04-15 20:46:34 +02:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
test("name", () {
|
|
|
|
final album = Album(
|
|
|
|
lastUpdated: DateTime.utc(2020, 1, 2, 3, 4, 5, 678, 901),
|
|
|
|
name: "album",
|
2021-06-24 18:26:56 +02:00
|
|
|
provider: AlbumStaticProvider(
|
|
|
|
items: [],
|
|
|
|
),
|
2021-06-26 13:51:13 +02:00
|
|
|
coverProvider: AlbumAutoCoverProvider(),
|
2021-09-15 08:58:06 +02:00
|
|
|
sortProvider: const AlbumNullSortProvider(),
|
2021-04-15 20:46:34 +02:00
|
|
|
);
|
|
|
|
expect(album.toAppDbJson(), <String, dynamic>{
|
|
|
|
"version": Album.version,
|
|
|
|
"lastUpdated": "2020-01-02T03:04:05.678901Z",
|
|
|
|
"name": "album",
|
2021-06-24 18:26:56 +02:00
|
|
|
"provider": <String, dynamic>{
|
|
|
|
"type": "static",
|
|
|
|
"content": <String, dynamic>{
|
|
|
|
"items": [],
|
|
|
|
},
|
|
|
|
},
|
2021-06-26 13:51:13 +02:00
|
|
|
"coverProvider": <String, dynamic>{
|
|
|
|
"type": "auto",
|
|
|
|
"content": <String, dynamic>{},
|
|
|
|
},
|
2021-07-07 20:40:43 +02:00
|
|
|
"sortProvider": <String, dynamic>{
|
|
|
|
"type": "null",
|
|
|
|
"content": <String, dynamic>{},
|
|
|
|
},
|
2021-04-15 20:46:34 +02:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2021-07-09 12:07:37 +02:00
|
|
|
group("AlbumStaticProvider", () {
|
|
|
|
test("AlbumFileItem", () {
|
|
|
|
final album = Album(
|
|
|
|
lastUpdated: DateTime.utc(2020, 1, 2, 3, 4, 5, 678, 901),
|
|
|
|
name: "",
|
|
|
|
provider: AlbumStaticProvider(
|
|
|
|
items: [
|
|
|
|
AlbumFileItem(
|
2021-11-12 22:13:02 +01:00
|
|
|
addedBy: "admin".toCi(),
|
2021-10-23 20:13:06 +02:00
|
|
|
addedAt: DateTime.utc(2020, 1, 2, 3, 4, 5, 678, 901),
|
2021-07-09 12:07:37 +02:00
|
|
|
file: File(path: "remote.php/dav/files/admin/test1.jpg"),
|
|
|
|
),
|
|
|
|
AlbumFileItem(
|
2021-11-12 22:13:02 +01:00
|
|
|
addedBy: "admin".toCi(),
|
2021-10-23 20:13:06 +02:00
|
|
|
addedAt: DateTime.utc(2020, 1, 2, 3, 4, 5, 678, 901),
|
2021-07-09 12:07:37 +02:00
|
|
|
file: File(path: "remote.php/dav/files/admin/test2.jpg"),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
coverProvider: AlbumAutoCoverProvider(),
|
2021-09-15 08:58:06 +02:00
|
|
|
sortProvider: const AlbumNullSortProvider(),
|
2021-07-09 12:07:37 +02:00
|
|
|
);
|
|
|
|
expect(album.toAppDbJson(), <String, dynamic>{
|
|
|
|
"version": Album.version,
|
|
|
|
"lastUpdated": "2020-01-02T03:04:05.678901Z",
|
|
|
|
"name": "",
|
|
|
|
"provider": <String, dynamic>{
|
|
|
|
"type": "static",
|
|
|
|
"content": <String, dynamic>{
|
|
|
|
"items": [
|
|
|
|
<String, dynamic>{
|
|
|
|
"type": "file",
|
|
|
|
"content": <String, dynamic>{
|
|
|
|
"file": <String, dynamic>{
|
|
|
|
"path": "remote.php/dav/files/admin/test1.jpg",
|
|
|
|
},
|
2021-06-24 18:26:56 +02:00
|
|
|
},
|
2021-10-23 20:13:06 +02:00
|
|
|
"addedBy": "admin",
|
|
|
|
"addedAt": "2020-01-02T03:04:05.678901Z",
|
2021-06-24 18:26:56 +02:00
|
|
|
},
|
2021-07-09 12:07:37 +02:00
|
|
|
<String, dynamic>{
|
|
|
|
"type": "file",
|
|
|
|
"content": <String, dynamic>{
|
|
|
|
"file": <String, dynamic>{
|
|
|
|
"path": "remote.php/dav/files/admin/test2.jpg",
|
|
|
|
},
|
2021-06-24 18:26:56 +02:00
|
|
|
},
|
2021-10-23 20:13:06 +02:00
|
|
|
"addedBy": "admin",
|
|
|
|
"addedAt": "2020-01-02T03:04:05.678901Z",
|
2021-06-24 18:26:56 +02:00
|
|
|
},
|
2021-07-09 12:07:37 +02:00
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"coverProvider": <String, dynamic>{
|
|
|
|
"type": "auto",
|
|
|
|
"content": <String, dynamic>{},
|
|
|
|
},
|
|
|
|
"sortProvider": <String, dynamic>{
|
|
|
|
"type": "null",
|
|
|
|
"content": <String, dynamic>{},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
test("AlbumLabelItem", () {
|
|
|
|
final album = Album(
|
|
|
|
lastUpdated: DateTime.utc(2020, 1, 2, 3, 4, 5, 678, 901),
|
|
|
|
name: "",
|
|
|
|
provider: AlbumStaticProvider(
|
|
|
|
items: [
|
|
|
|
AlbumLabelItem(
|
2021-11-12 22:13:02 +01:00
|
|
|
addedBy: "admin".toCi(),
|
2021-10-23 20:13:06 +02:00
|
|
|
addedAt: DateTime.utc(2020, 1, 2, 3, 4, 5, 678, 901),
|
2021-07-09 12:07:37 +02:00
|
|
|
text: "Testing",
|
|
|
|
),
|
2021-06-24 18:26:56 +02:00
|
|
|
],
|
2021-07-09 12:07:37 +02:00
|
|
|
),
|
|
|
|
coverProvider: AlbumAutoCoverProvider(),
|
2021-09-15 08:58:06 +02:00
|
|
|
sortProvider: const AlbumNullSortProvider(),
|
2021-07-09 12:07:37 +02:00
|
|
|
);
|
|
|
|
expect(album.toAppDbJson(), <String, dynamic>{
|
|
|
|
"version": Album.version,
|
|
|
|
"lastUpdated": "2020-01-02T03:04:05.678901Z",
|
|
|
|
"name": "",
|
|
|
|
"provider": <String, dynamic>{
|
|
|
|
"type": "static",
|
|
|
|
"content": <String, dynamic>{
|
|
|
|
"items": [
|
|
|
|
<String, dynamic>{
|
|
|
|
"type": "label",
|
|
|
|
"content": <String, dynamic>{
|
|
|
|
"text": "Testing",
|
|
|
|
},
|
2021-10-23 20:13:06 +02:00
|
|
|
"addedBy": "admin",
|
|
|
|
"addedAt": "2020-01-02T03:04:05.678901Z",
|
2021-07-09 12:07:37 +02:00
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
2021-04-15 20:46:34 +02:00
|
|
|
},
|
2021-07-09 12:07:37 +02:00
|
|
|
"coverProvider": <String, dynamic>{
|
|
|
|
"type": "auto",
|
|
|
|
"content": <String, dynamic>{},
|
|
|
|
},
|
|
|
|
"sortProvider": <String, dynamic>{
|
|
|
|
"type": "null",
|
|
|
|
"content": <String, dynamic>{},
|
|
|
|
},
|
|
|
|
});
|
2021-06-26 13:51:13 +02:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
test("AlbumAutoCoverProvider", () {
|
|
|
|
final album = Album(
|
|
|
|
lastUpdated: DateTime.utc(2020, 1, 2, 3, 4, 5, 678, 901),
|
|
|
|
name: "",
|
|
|
|
provider: AlbumStaticProvider(
|
|
|
|
items: [],
|
|
|
|
),
|
|
|
|
coverProvider: AlbumAutoCoverProvider(
|
|
|
|
coverFile: File(
|
|
|
|
path: "remote.php/dav/files/admin/test1.jpg",
|
|
|
|
),
|
|
|
|
),
|
2021-09-15 08:58:06 +02:00
|
|
|
sortProvider: const AlbumNullSortProvider(),
|
2021-06-26 13:51:13 +02:00
|
|
|
);
|
|
|
|
expect(album.toAppDbJson(), <String, dynamic>{
|
|
|
|
"version": Album.version,
|
|
|
|
"lastUpdated": "2020-01-02T03:04:05.678901Z",
|
|
|
|
"name": "",
|
|
|
|
"provider": <String, dynamic>{
|
|
|
|
"type": "static",
|
|
|
|
"content": <String, dynamic>{
|
|
|
|
"items": [],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"coverProvider": <String, dynamic>{
|
|
|
|
"type": "auto",
|
|
|
|
"content": <String, dynamic>{
|
|
|
|
"coverFile": <String, dynamic>{
|
|
|
|
"path": "remote.php/dav/files/admin/test1.jpg",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-07-07 20:40:43 +02:00
|
|
|
"sortProvider": <String, dynamic>{
|
|
|
|
"type": "null",
|
|
|
|
"content": <String, dynamic>{},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
test("AlbumTimeSortProvider", () {
|
|
|
|
final album = Album(
|
|
|
|
lastUpdated: DateTime.utc(2020, 1, 2, 3, 4, 5, 678, 901),
|
|
|
|
name: "",
|
|
|
|
provider: AlbumStaticProvider(
|
|
|
|
items: [],
|
|
|
|
),
|
|
|
|
coverProvider: AlbumAutoCoverProvider(),
|
2021-09-15 08:58:06 +02:00
|
|
|
sortProvider: const AlbumTimeSortProvider(
|
2021-07-07 20:40:43 +02:00
|
|
|
isAscending: true,
|
|
|
|
),
|
|
|
|
);
|
|
|
|
expect(album.toAppDbJson(), <String, dynamic>{
|
|
|
|
"version": Album.version,
|
|
|
|
"lastUpdated": "2020-01-02T03:04:05.678901Z",
|
|
|
|
"name": "",
|
|
|
|
"provider": <String, dynamic>{
|
|
|
|
"type": "static",
|
|
|
|
"content": <String, dynamic>{
|
|
|
|
"items": [],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"coverProvider": <String, dynamic>{
|
|
|
|
"type": "auto",
|
|
|
|
"content": <String, dynamic>{},
|
|
|
|
},
|
|
|
|
"sortProvider": <String, dynamic>{
|
|
|
|
"type": "time",
|
|
|
|
"content": <String, dynamic>{
|
|
|
|
"isAscending": true,
|
|
|
|
},
|
|
|
|
},
|
2021-04-15 20:46:34 +02:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2021-11-11 18:03:36 +01:00
|
|
|
test("shares", _toAppDbJsonShares);
|
|
|
|
|
2021-04-15 20:46:34 +02:00
|
|
|
test("albumFile", () {
|
|
|
|
final album = Album(
|
|
|
|
lastUpdated: DateTime.utc(2020, 1, 2, 3, 4, 5, 678, 901),
|
|
|
|
name: "",
|
2021-06-24 18:26:56 +02:00
|
|
|
provider: AlbumStaticProvider(
|
|
|
|
items: [],
|
|
|
|
),
|
2021-06-26 13:51:13 +02:00
|
|
|
coverProvider: AlbumAutoCoverProvider(),
|
2021-09-15 08:58:06 +02:00
|
|
|
sortProvider: const AlbumNullSortProvider(),
|
2021-05-25 21:55:25 +02:00
|
|
|
albumFile: File(path: "remote.php/dav/files/admin/test1.jpg"),
|
2021-04-15 20:46:34 +02:00
|
|
|
);
|
|
|
|
expect(album.toAppDbJson(), <String, dynamic>{
|
|
|
|
"version": Album.version,
|
|
|
|
"lastUpdated": "2020-01-02T03:04:05.678901Z",
|
|
|
|
"name": "",
|
2021-06-24 18:26:56 +02:00
|
|
|
"provider": <String, dynamic>{
|
|
|
|
"type": "static",
|
|
|
|
"content": <String, dynamic>{
|
|
|
|
"items": [],
|
|
|
|
},
|
|
|
|
},
|
2021-06-26 13:51:13 +02:00
|
|
|
"coverProvider": <String, dynamic>{
|
|
|
|
"type": "auto",
|
|
|
|
"content": <String, dynamic>{},
|
|
|
|
},
|
2021-07-07 20:40:43 +02:00
|
|
|
"sortProvider": <String, dynamic>{
|
|
|
|
"type": "null",
|
|
|
|
"content": <String, dynamic>{},
|
|
|
|
},
|
2021-04-15 20:46:34 +02:00
|
|
|
"albumFile": <String, dynamic>{
|
2021-05-25 21:55:25 +02:00
|
|
|
"path": "remote.php/dav/files/admin/test1.jpg",
|
2021-04-15 20:46:34 +02:00
|
|
|
},
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2021-06-24 16:54:41 +02:00
|
|
|
test("AlbumUpgraderV1", () {
|
|
|
|
final json = <String, dynamic>{
|
|
|
|
"version": 1,
|
|
|
|
"lastUpdated": "2020-01-02T03:04:05.678901Z",
|
|
|
|
"items": [
|
|
|
|
<String, dynamic>{
|
|
|
|
"type": "file",
|
|
|
|
"content": <String, dynamic>{
|
|
|
|
"file": <String, dynamic>{
|
|
|
|
"path": "remote.php/dav/files/admin/test1.jpg",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
"albumFile": <String, dynamic>{
|
|
|
|
"path": "remote.php/dav/files/admin/test1.json",
|
|
|
|
},
|
|
|
|
};
|
|
|
|
expect(AlbumUpgraderV1()(json), <String, dynamic>{
|
|
|
|
"version": 1,
|
|
|
|
"lastUpdated": "2020-01-02T03:04:05.678901Z",
|
|
|
|
"items": [],
|
|
|
|
"albumFile": <String, dynamic>{
|
|
|
|
"path": "remote.php/dav/files/admin/test1.json",
|
|
|
|
},
|
2021-04-15 20:46:34 +02:00
|
|
|
});
|
|
|
|
});
|
2021-06-24 18:26:56 +02:00
|
|
|
|
|
|
|
test("AlbumUpgraderV2", () {
|
|
|
|
final json = <String, dynamic>{
|
|
|
|
"version": 2,
|
|
|
|
"lastUpdated": "2020-01-02T03:04:05.678901Z",
|
|
|
|
"items": [
|
|
|
|
<String, dynamic>{
|
|
|
|
"type": "file",
|
|
|
|
"content": <String, dynamic>{
|
|
|
|
"file": <String, dynamic>{
|
|
|
|
"path": "remote.php/dav/files/admin/test1.jpg",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
"albumFile": <String, dynamic>{
|
|
|
|
"path": "remote.php/dav/files/admin/test1.json",
|
|
|
|
},
|
|
|
|
};
|
|
|
|
expect(AlbumUpgraderV2()(json), <String, dynamic>{
|
|
|
|
"version": 2,
|
|
|
|
"lastUpdated": "2020-01-02T03:04:05.678901Z",
|
|
|
|
"provider": <String, dynamic>{
|
|
|
|
"type": "static",
|
|
|
|
"content": <String, dynamic>{
|
|
|
|
"items": [
|
|
|
|
<String, dynamic>{
|
|
|
|
"type": "file",
|
|
|
|
"content": <String, dynamic>{
|
|
|
|
"file": <String, dynamic>{
|
|
|
|
"path": "remote.php/dav/files/admin/test1.jpg",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
2021-06-26 13:51:13 +02:00
|
|
|
"coverProvider": <String, dynamic>{
|
|
|
|
"type": "auto",
|
|
|
|
"content": <String, dynamic>{},
|
|
|
|
},
|
2021-06-24 18:26:56 +02:00
|
|
|
"albumFile": <String, dynamic>{
|
|
|
|
"path": "remote.php/dav/files/admin/test1.json",
|
|
|
|
},
|
|
|
|
});
|
|
|
|
});
|
2021-07-07 20:40:43 +02:00
|
|
|
|
|
|
|
test("AlbumUpgraderV3", () {
|
|
|
|
final json = <String, dynamic>{
|
|
|
|
"version": 3,
|
|
|
|
"lastUpdated": "2020-01-02T03:04:05.678901Z",
|
|
|
|
"provider": <String, dynamic>{
|
|
|
|
"type": "static",
|
|
|
|
"content": <String, dynamic>{
|
|
|
|
"items": [
|
|
|
|
<String, dynamic>{
|
|
|
|
"type": "file",
|
|
|
|
"content": <String, dynamic>{
|
|
|
|
"file": <String, dynamic>{
|
|
|
|
"path": "remote.php/dav/files/admin/test1.jpg",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"coverProvider": <String, dynamic>{
|
|
|
|
"type": "auto",
|
|
|
|
"content": <String, dynamic>{},
|
|
|
|
},
|
|
|
|
"albumFile": <String, dynamic>{
|
|
|
|
"path": "remote.php/dav/files/admin/test1.json",
|
|
|
|
},
|
|
|
|
};
|
|
|
|
expect(AlbumUpgraderV3()(json), <String, dynamic>{
|
|
|
|
"version": 3,
|
|
|
|
"lastUpdated": "2020-01-02T03:04:05.678901Z",
|
|
|
|
"provider": <String, dynamic>{
|
|
|
|
"type": "static",
|
|
|
|
"content": <String, dynamic>{
|
|
|
|
"items": [
|
|
|
|
<String, dynamic>{
|
|
|
|
"type": "file",
|
|
|
|
"content": <String, dynamic>{
|
|
|
|
"file": <String, dynamic>{
|
|
|
|
"path": "remote.php/dav/files/admin/test1.jpg",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"coverProvider": <String, dynamic>{
|
|
|
|
"type": "auto",
|
|
|
|
"content": <String, dynamic>{},
|
|
|
|
},
|
|
|
|
"sortProvider": <String, dynamic>{
|
|
|
|
"type": "time",
|
|
|
|
"content": <String, dynamic>{
|
|
|
|
"isAscending": false,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"albumFile": <String, dynamic>{
|
|
|
|
"path": "remote.php/dav/files/admin/test1.json",
|
|
|
|
},
|
|
|
|
});
|
|
|
|
});
|
2021-09-25 18:22:19 +02:00
|
|
|
|
|
|
|
group("AlbumUpgraderV4", () {
|
|
|
|
test("Non AlbumFileItem", () {
|
|
|
|
final json = <String, dynamic>{
|
|
|
|
"version": 4,
|
|
|
|
"lastUpdated": "2020-01-02T03:04:05.678901Z",
|
|
|
|
"provider": <String, dynamic>{
|
|
|
|
"type": "static",
|
|
|
|
"content": <String, dynamic>{
|
|
|
|
"items": [
|
|
|
|
<String, dynamic>{
|
|
|
|
"type": "label",
|
|
|
|
"content": <String, dynamic>{
|
|
|
|
"text": "123",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"coverProvider": <String, dynamic>{
|
|
|
|
"type": "auto",
|
|
|
|
"content": <String, dynamic>{},
|
|
|
|
},
|
|
|
|
"sortProvider": <String, dynamic>{
|
|
|
|
"type": "time",
|
|
|
|
"content": <String, dynamic>{
|
|
|
|
"isAscending": false,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"albumFile": <String, dynamic>{
|
|
|
|
"path": "remote.php/dav/files/admin/test1.json",
|
|
|
|
},
|
|
|
|
};
|
|
|
|
expect(AlbumUpgraderV4()(json), <String, dynamic>{
|
|
|
|
"version": 4,
|
|
|
|
"lastUpdated": "2020-01-02T03:04:05.678901Z",
|
|
|
|
"provider": <String, dynamic>{
|
|
|
|
"type": "static",
|
|
|
|
"content": <String, dynamic>{
|
|
|
|
"items": [
|
|
|
|
<String, dynamic>{
|
|
|
|
"type": "label",
|
|
|
|
"content": <String, dynamic>{
|
|
|
|
"text": "123",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"coverProvider": <String, dynamic>{
|
|
|
|
"type": "auto",
|
|
|
|
"content": <String, dynamic>{},
|
|
|
|
},
|
|
|
|
"sortProvider": <String, dynamic>{
|
|
|
|
"type": "time",
|
|
|
|
"content": <String, dynamic>{
|
|
|
|
"isAscending": false,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"albumFile": <String, dynamic>{
|
|
|
|
"path": "remote.php/dav/files/admin/test1.json",
|
|
|
|
},
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
group("AlbumFileItem", () {
|
|
|
|
test("drop metadata", () {
|
|
|
|
final json = <String, dynamic>{
|
|
|
|
"version": 4,
|
|
|
|
"lastUpdated": "2020-01-02T03:04:05.678901Z",
|
|
|
|
"provider": <String, dynamic>{
|
|
|
|
"type": "static",
|
|
|
|
"content": <String, dynamic>{
|
|
|
|
"items": [
|
|
|
|
<String, dynamic>{
|
|
|
|
"type": "file",
|
|
|
|
"content": <String, dynamic>{
|
|
|
|
"file": <String, dynamic>{
|
|
|
|
"path": "remote.php/dav/files/admin/test1.jpg",
|
|
|
|
"metadata": <String, dynamic>{
|
|
|
|
"Make": "Super",
|
|
|
|
"Model": "A123",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"coverProvider": <String, dynamic>{
|
|
|
|
"type": "auto",
|
|
|
|
"content": <String, dynamic>{},
|
|
|
|
},
|
|
|
|
"sortProvider": <String, dynamic>{
|
|
|
|
"type": "time",
|
|
|
|
"content": <String, dynamic>{
|
|
|
|
"isAscending": false,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"albumFile": <String, dynamic>{
|
|
|
|
"path": "remote.php/dav/files/admin/test1.json",
|
|
|
|
},
|
|
|
|
};
|
|
|
|
expect(AlbumUpgraderV4()(json), <String, dynamic>{
|
|
|
|
"version": 4,
|
|
|
|
"lastUpdated": "2020-01-02T03:04:05.678901Z",
|
|
|
|
"provider": <String, dynamic>{
|
|
|
|
"type": "static",
|
|
|
|
"content": <String, dynamic>{
|
|
|
|
"items": [
|
|
|
|
<String, dynamic>{
|
|
|
|
"type": "file",
|
|
|
|
"content": <String, dynamic>{
|
|
|
|
"file": <String, dynamic>{
|
|
|
|
"path": "remote.php/dav/files/admin/test1.jpg",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"coverProvider": <String, dynamic>{
|
|
|
|
"type": "auto",
|
|
|
|
"content": <String, dynamic>{},
|
|
|
|
},
|
|
|
|
"sortProvider": <String, dynamic>{
|
|
|
|
"type": "time",
|
|
|
|
"content": <String, dynamic>{
|
|
|
|
"isAscending": false,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"albumFile": <String, dynamic>{
|
|
|
|
"path": "remote.php/dav/files/admin/test1.json",
|
|
|
|
},
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
test("lastModified as latestItemTime", () {
|
|
|
|
final json = <String, dynamic>{
|
|
|
|
"version": 4,
|
|
|
|
"lastUpdated": "2020-01-02T03:04:05.678901Z",
|
|
|
|
"provider": <String, dynamic>{
|
|
|
|
"type": "static",
|
|
|
|
"content": <String, dynamic>{
|
|
|
|
"items": [
|
|
|
|
<String, dynamic>{
|
|
|
|
"type": "file",
|
|
|
|
"content": <String, dynamic>{
|
|
|
|
"file": <String, dynamic>{
|
|
|
|
"path": "remote.php/dav/files/admin/test1.jpg",
|
|
|
|
"lastModified": "2020-01-02T03:04:05.678901Z",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"coverProvider": <String, dynamic>{
|
|
|
|
"type": "auto",
|
|
|
|
"content": <String, dynamic>{},
|
|
|
|
},
|
|
|
|
"sortProvider": <String, dynamic>{
|
|
|
|
"type": "time",
|
|
|
|
"content": <String, dynamic>{
|
|
|
|
"isAscending": false,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"albumFile": <String, dynamic>{
|
|
|
|
"path": "remote.php/dav/files/admin/test1.json",
|
|
|
|
},
|
|
|
|
};
|
|
|
|
expect(AlbumUpgraderV4()(json), <String, dynamic>{
|
|
|
|
"version": 4,
|
|
|
|
"lastUpdated": "2020-01-02T03:04:05.678901Z",
|
|
|
|
"provider": <String, dynamic>{
|
|
|
|
"type": "static",
|
|
|
|
"content": <String, dynamic>{
|
|
|
|
"latestItemTime": "2020-01-02T03:04:05.678901Z",
|
|
|
|
"items": [
|
|
|
|
<String, dynamic>{
|
|
|
|
"type": "file",
|
|
|
|
"content": <String, dynamic>{
|
|
|
|
"file": <String, dynamic>{
|
|
|
|
"path": "remote.php/dav/files/admin/test1.jpg",
|
|
|
|
"lastModified": "2020-01-02T03:04:05.678901Z",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"coverProvider": <String, dynamic>{
|
|
|
|
"type": "auto",
|
|
|
|
"content": <String, dynamic>{
|
|
|
|
"coverFile": <String, dynamic>{
|
|
|
|
"path": "remote.php/dav/files/admin/test1.jpg",
|
|
|
|
"lastModified": "2020-01-02T03:04:05.678901Z",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"sortProvider": <String, dynamic>{
|
|
|
|
"type": "time",
|
|
|
|
"content": <String, dynamic>{
|
|
|
|
"isAscending": false,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"albumFile": <String, dynamic>{
|
|
|
|
"path": "remote.php/dav/files/admin/test1.json",
|
|
|
|
},
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
test("dateTimeOriginal as latestItemTime", () {
|
|
|
|
final json = <String, dynamic>{
|
|
|
|
"version": 4,
|
|
|
|
"lastUpdated": "2020-01-02T03:04:05.678901Z",
|
|
|
|
"provider": <String, dynamic>{
|
|
|
|
"type": "static",
|
|
|
|
"content": <String, dynamic>{
|
|
|
|
"items": [
|
|
|
|
<String, dynamic>{
|
|
|
|
"type": "file",
|
|
|
|
"content": <String, dynamic>{
|
|
|
|
"file": <String, dynamic>{
|
|
|
|
"path": "remote.php/dav/files/admin/test1.jpg",
|
|
|
|
"metadata": <String, dynamic>{
|
|
|
|
"exif": <String, dynamic>{
|
|
|
|
// convert 2020-01-02T03:04:05Z to local time
|
|
|
|
"DateTimeOriginal":
|
|
|
|
DateFormat("yyyy:MM:dd HH:mm:ss").format(
|
|
|
|
DateTime.utc(2020, 1, 2, 3, 4, 5)
|
|
|
|
.toLocal()),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"coverProvider": <String, dynamic>{
|
|
|
|
"type": "auto",
|
|
|
|
"content": <String, dynamic>{},
|
|
|
|
},
|
|
|
|
"sortProvider": <String, dynamic>{
|
|
|
|
"type": "time",
|
|
|
|
"content": <String, dynamic>{
|
|
|
|
"isAscending": false,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"albumFile": <String, dynamic>{
|
|
|
|
"path": "remote.php/dav/files/admin/test1.json",
|
|
|
|
},
|
|
|
|
};
|
|
|
|
expect(AlbumUpgraderV4()(json), <String, dynamic>{
|
|
|
|
"version": 4,
|
|
|
|
"lastUpdated": "2020-01-02T03:04:05.678901Z",
|
|
|
|
"provider": <String, dynamic>{
|
|
|
|
"type": "static",
|
|
|
|
"content": <String, dynamic>{
|
|
|
|
"latestItemTime": "2020-01-02T03:04:05.000Z",
|
|
|
|
"items": [
|
|
|
|
<String, dynamic>{
|
|
|
|
"type": "file",
|
|
|
|
"content": <String, dynamic>{
|
|
|
|
"file": <String, dynamic>{
|
|
|
|
"path": "remote.php/dav/files/admin/test1.jpg",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"coverProvider": <String, dynamic>{
|
|
|
|
"type": "auto",
|
|
|
|
"content": <String, dynamic>{
|
|
|
|
"coverFile": <String, dynamic>{
|
|
|
|
"path": "remote.php/dav/files/admin/test1.jpg",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"sortProvider": <String, dynamic>{
|
|
|
|
"type": "time",
|
|
|
|
"content": <String, dynamic>{
|
|
|
|
"isAscending": false,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"albumFile": <String, dynamic>{
|
|
|
|
"path": "remote.php/dav/files/admin/test1.json",
|
|
|
|
},
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
test("overrideDateTime as latestItemTime", () {
|
|
|
|
final json = <String, dynamic>{
|
|
|
|
"version": 4,
|
|
|
|
"lastUpdated": "2020-01-02T03:04:05.678901Z",
|
|
|
|
"provider": <String, dynamic>{
|
|
|
|
"type": "static",
|
|
|
|
"content": <String, dynamic>{
|
|
|
|
"items": [
|
|
|
|
<String, dynamic>{
|
|
|
|
"type": "file",
|
|
|
|
"content": <String, dynamic>{
|
|
|
|
"file": <String, dynamic>{
|
|
|
|
"path": "remote.php/dav/files/admin/test1.jpg",
|
|
|
|
"overrideDateTime": "2020-01-02T03:04:05.678901Z",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"coverProvider": <String, dynamic>{
|
|
|
|
"type": "auto",
|
|
|
|
"content": <String, dynamic>{},
|
|
|
|
},
|
|
|
|
"sortProvider": <String, dynamic>{
|
|
|
|
"type": "time",
|
|
|
|
"content": <String, dynamic>{
|
|
|
|
"isAscending": false,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"albumFile": <String, dynamic>{
|
|
|
|
"path": "remote.php/dav/files/admin/test1.json",
|
|
|
|
},
|
|
|
|
};
|
|
|
|
expect(AlbumUpgraderV4()(json), <String, dynamic>{
|
|
|
|
"version": 4,
|
|
|
|
"lastUpdated": "2020-01-02T03:04:05.678901Z",
|
|
|
|
"provider": <String, dynamic>{
|
|
|
|
"type": "static",
|
|
|
|
"content": <String, dynamic>{
|
|
|
|
"latestItemTime": "2020-01-02T03:04:05.678901Z",
|
|
|
|
"items": [
|
|
|
|
<String, dynamic>{
|
|
|
|
"type": "file",
|
|
|
|
"content": <String, dynamic>{
|
|
|
|
"file": <String, dynamic>{
|
|
|
|
"path": "remote.php/dav/files/admin/test1.jpg",
|
|
|
|
"overrideDateTime": "2020-01-02T03:04:05.678901Z",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"coverProvider": <String, dynamic>{
|
|
|
|
"type": "auto",
|
|
|
|
"content": <String, dynamic>{
|
|
|
|
"coverFile": <String, dynamic>{
|
|
|
|
"path": "remote.php/dav/files/admin/test1.jpg",
|
|
|
|
"overrideDateTime": "2020-01-02T03:04:05.678901Z",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"sortProvider": <String, dynamic>{
|
|
|
|
"type": "time",
|
|
|
|
"content": <String, dynamic>{
|
|
|
|
"isAscending": false,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"albumFile": <String, dynamic>{
|
|
|
|
"path": "remote.php/dav/files/admin/test1.json",
|
|
|
|
},
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2021-10-23 20:13:06 +02:00
|
|
|
|
|
|
|
group("AlbumUpgraderV5", () {
|
2021-11-12 22:13:02 +01:00
|
|
|
final account = test_util.buildAccount(username: "user1");
|
2021-10-23 20:13:06 +02:00
|
|
|
|
|
|
|
test("w/ ownerId", () {
|
|
|
|
final json = <String, dynamic>{
|
|
|
|
"version": 5,
|
|
|
|
"lastUpdated": "2020-01-02T03:04:05.678901Z",
|
|
|
|
"provider": <String, dynamic>{
|
|
|
|
"type": "static",
|
|
|
|
"content": <String, dynamic>{
|
|
|
|
"items": [
|
|
|
|
<String, dynamic>{
|
|
|
|
"type": "file",
|
|
|
|
"content": <String, dynamic>{
|
|
|
|
"file": <String, dynamic>{
|
|
|
|
"path": "remote.php/dav/files/admin/test1.jpg",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"coverProvider": <String, dynamic>{
|
|
|
|
"type": "auto",
|
|
|
|
"content": <String, dynamic>{},
|
|
|
|
},
|
|
|
|
"sortProvider": <String, dynamic>{
|
|
|
|
"type": "time",
|
|
|
|
"content": <String, dynamic>{
|
|
|
|
"isAscending": false,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"albumFile": <String, dynamic>{
|
|
|
|
"path": "remote.php/dav/files/admin/test1.json",
|
|
|
|
"ownerId": "admin",
|
|
|
|
},
|
|
|
|
};
|
|
|
|
expect(AlbumUpgraderV5(account)(json), <String, dynamic>{
|
|
|
|
"version": 5,
|
|
|
|
"lastUpdated": "2020-01-02T03:04:05.678901Z",
|
|
|
|
"provider": <String, dynamic>{
|
|
|
|
"type": "static",
|
|
|
|
"content": <String, dynamic>{
|
|
|
|
"items": [
|
|
|
|
<String, dynamic>{
|
|
|
|
"type": "file",
|
|
|
|
"content": <String, dynamic>{
|
|
|
|
"file": <String, dynamic>{
|
|
|
|
"path": "remote.php/dav/files/admin/test1.jpg",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"addedBy": "admin",
|
|
|
|
"addedAt": "2020-01-02T03:04:05.678901Z",
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"coverProvider": <String, dynamic>{
|
|
|
|
"type": "auto",
|
|
|
|
"content": <String, dynamic>{},
|
|
|
|
},
|
|
|
|
"sortProvider": <String, dynamic>{
|
|
|
|
"type": "time",
|
|
|
|
"content": <String, dynamic>{
|
|
|
|
"isAscending": false,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"albumFile": <String, dynamic>{
|
|
|
|
"path": "remote.php/dav/files/admin/test1.json",
|
|
|
|
"ownerId": "admin",
|
|
|
|
},
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
test("w/o ownerId", () {
|
|
|
|
final json = <String, dynamic>{
|
|
|
|
"version": 5,
|
|
|
|
"lastUpdated": "2020-01-02T03:04:05.678901Z",
|
|
|
|
"provider": <String, dynamic>{
|
|
|
|
"type": "static",
|
|
|
|
"content": <String, dynamic>{
|
|
|
|
"items": [
|
|
|
|
<String, dynamic>{
|
|
|
|
"type": "file",
|
|
|
|
"content": <String, dynamic>{
|
|
|
|
"file": <String, dynamic>{
|
|
|
|
"path": "remote.php/dav/files/admin/test1.jpg",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"coverProvider": <String, dynamic>{
|
|
|
|
"type": "auto",
|
|
|
|
"content": <String, dynamic>{},
|
|
|
|
},
|
|
|
|
"sortProvider": <String, dynamic>{
|
|
|
|
"type": "time",
|
|
|
|
"content": <String, dynamic>{
|
|
|
|
"isAscending": false,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"albumFile": <String, dynamic>{
|
|
|
|
"path": "remote.php/dav/files/admin/test1.json",
|
|
|
|
},
|
|
|
|
};
|
|
|
|
expect(AlbumUpgraderV5(account)(json), <String, dynamic>{
|
|
|
|
"version": 5,
|
|
|
|
"lastUpdated": "2020-01-02T03:04:05.678901Z",
|
|
|
|
"provider": <String, dynamic>{
|
|
|
|
"type": "static",
|
|
|
|
"content": <String, dynamic>{
|
|
|
|
"items": [
|
|
|
|
<String, dynamic>{
|
|
|
|
"type": "file",
|
|
|
|
"content": <String, dynamic>{
|
|
|
|
"file": <String, dynamic>{
|
|
|
|
"path": "remote.php/dav/files/admin/test1.jpg",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"addedBy": "user1",
|
|
|
|
"addedAt": "2020-01-02T03:04:05.678901Z",
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"coverProvider": <String, dynamic>{
|
|
|
|
"type": "auto",
|
|
|
|
"content": <String, dynamic>{},
|
|
|
|
},
|
|
|
|
"sortProvider": <String, dynamic>{
|
|
|
|
"type": "time",
|
|
|
|
"content": <String, dynamic>{
|
|
|
|
"isAscending": false,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"albumFile": <String, dynamic>{
|
|
|
|
"path": "remote.php/dav/files/admin/test1.json",
|
|
|
|
},
|
|
|
|
});
|
|
|
|
});
|
2021-10-31 14:07:05 +01:00
|
|
|
|
|
|
|
test("w/o albumFile", () {
|
|
|
|
final json = <String, dynamic>{
|
|
|
|
"version": 5,
|
|
|
|
"lastUpdated": "2020-01-02T03:04:05.678901Z",
|
|
|
|
"provider": <String, dynamic>{
|
|
|
|
"type": "static",
|
|
|
|
"content": <String, dynamic>{
|
|
|
|
"items": [
|
|
|
|
<String, dynamic>{
|
|
|
|
"type": "file",
|
|
|
|
"content": <String, dynamic>{
|
|
|
|
"file": <String, dynamic>{
|
|
|
|
"path": "remote.php/dav/files/admin/test1.jpg",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"coverProvider": <String, dynamic>{
|
|
|
|
"type": "auto",
|
|
|
|
"content": <String, dynamic>{},
|
|
|
|
},
|
|
|
|
"sortProvider": <String, dynamic>{
|
|
|
|
"type": "time",
|
|
|
|
"content": <String, dynamic>{
|
|
|
|
"isAscending": false,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
expect(AlbumUpgraderV5(account)(json), <String, dynamic>{
|
|
|
|
"version": 5,
|
|
|
|
"lastUpdated": "2020-01-02T03:04:05.678901Z",
|
|
|
|
"provider": <String, dynamic>{
|
|
|
|
"type": "static",
|
|
|
|
"content": <String, dynamic>{
|
|
|
|
"items": [
|
|
|
|
<String, dynamic>{
|
|
|
|
"type": "file",
|
|
|
|
"content": <String, dynamic>{
|
|
|
|
"file": <String, dynamic>{
|
|
|
|
"path": "remote.php/dav/files/admin/test1.jpg",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"addedBy": "user1",
|
|
|
|
"addedAt": "2020-01-02T03:04:05.678901Z",
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"coverProvider": <String, dynamic>{
|
|
|
|
"type": "auto",
|
|
|
|
"content": <String, dynamic>{},
|
|
|
|
},
|
|
|
|
"sortProvider": <String, dynamic>{
|
|
|
|
"type": "time",
|
|
|
|
"content": <String, dynamic>{
|
|
|
|
"isAscending": false,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
test("w/ external albumFile", () {
|
|
|
|
final json = <String, dynamic>{
|
|
|
|
"version": 5,
|
|
|
|
"lastUpdated": "2020-01-02T03:04:05.678901Z",
|
|
|
|
"provider": <String, dynamic>{
|
|
|
|
"type": "static",
|
|
|
|
"content": <String, dynamic>{
|
|
|
|
"items": [
|
|
|
|
<String, dynamic>{
|
|
|
|
"type": "file",
|
|
|
|
"content": <String, dynamic>{
|
|
|
|
"file": <String, dynamic>{
|
|
|
|
"path": "remote.php/dav/files/admin/test1.jpg",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"coverProvider": <String, dynamic>{
|
|
|
|
"type": "auto",
|
|
|
|
"content": <String, dynamic>{},
|
|
|
|
},
|
|
|
|
"sortProvider": <String, dynamic>{
|
|
|
|
"type": "time",
|
|
|
|
"content": <String, dynamic>{
|
|
|
|
"isAscending": false,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
final albumFile = File(
|
|
|
|
path: "remote.php/dav/files/admin/test1.json",
|
2021-11-12 22:13:02 +01:00
|
|
|
ownerId: "admin".toCi(),
|
2021-10-31 14:07:05 +01:00
|
|
|
);
|
|
|
|
expect(
|
|
|
|
AlbumUpgraderV5(account, albumFile: albumFile)(json),
|
|
|
|
<String, dynamic>{
|
|
|
|
"version": 5,
|
|
|
|
"lastUpdated": "2020-01-02T03:04:05.678901Z",
|
|
|
|
"provider": <String, dynamic>{
|
|
|
|
"type": "static",
|
|
|
|
"content": <String, dynamic>{
|
|
|
|
"items": [
|
|
|
|
<String, dynamic>{
|
|
|
|
"type": "file",
|
|
|
|
"content": <String, dynamic>{
|
|
|
|
"file": <String, dynamic>{
|
|
|
|
"path": "remote.php/dav/files/admin/test1.jpg",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"addedBy": "admin",
|
|
|
|
"addedAt": "2020-01-02T03:04:05.678901Z",
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"coverProvider": <String, dynamic>{
|
|
|
|
"type": "auto",
|
|
|
|
"content": <String, dynamic>{},
|
|
|
|
},
|
|
|
|
"sortProvider": <String, dynamic>{
|
|
|
|
"type": "time",
|
|
|
|
"content": <String, dynamic>{
|
|
|
|
"isAscending": false,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
});
|
2021-10-23 20:13:06 +02:00
|
|
|
});
|
2021-04-15 20:46:34 +02:00
|
|
|
});
|
|
|
|
}
|
2021-11-11 18:03:36 +01:00
|
|
|
|
|
|
|
void _fromJsonShares() {
|
|
|
|
final json = <String, dynamic>{
|
|
|
|
"version": Album.version,
|
|
|
|
"lastUpdated": "2020-01-02T03:04:05.678901Z",
|
|
|
|
"name": "",
|
|
|
|
"provider": <String, dynamic>{
|
|
|
|
"type": "static",
|
|
|
|
"content": <String, dynamic>{
|
|
|
|
"items": [],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"coverProvider": <String, dynamic>{
|
|
|
|
"type": "auto",
|
|
|
|
"content": <String, dynamic>{},
|
|
|
|
},
|
|
|
|
"sortProvider": <String, dynamic>{
|
|
|
|
"type": "null",
|
|
|
|
"content": <String, dynamic>{},
|
|
|
|
},
|
|
|
|
"shares": <JsonObj>[
|
|
|
|
{"userId": "admin"},
|
|
|
|
],
|
|
|
|
};
|
|
|
|
expect(
|
|
|
|
Album.fromJson(
|
|
|
|
json,
|
2021-11-18 09:43:14 +01:00
|
|
|
upgraderFactory: const _NullAlbumUpgraderFactory(),
|
2021-11-11 18:03:36 +01:00
|
|
|
),
|
|
|
|
Album(
|
|
|
|
lastUpdated: DateTime.utc(2020, 1, 2, 3, 4, 5, 678, 901),
|
|
|
|
name: "",
|
|
|
|
provider: AlbumStaticProvider(
|
|
|
|
items: [],
|
|
|
|
),
|
|
|
|
coverProvider: AlbumAutoCoverProvider(),
|
|
|
|
sortProvider: const AlbumNullSortProvider(),
|
|
|
|
shares: [AlbumShare(userId: "admin".toCi())],
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
|
|
|
void _toRemoteJsonShares() {
|
|
|
|
final album = Album(
|
|
|
|
lastUpdated: DateTime.utc(2020, 1, 2, 3, 4, 5, 678, 901),
|
|
|
|
name: "",
|
|
|
|
provider: AlbumStaticProvider(
|
|
|
|
items: [],
|
|
|
|
),
|
|
|
|
coverProvider: AlbumAutoCoverProvider(),
|
|
|
|
sortProvider: const AlbumNullSortProvider(),
|
|
|
|
shares: [AlbumShare(userId: "admin".toCi())],
|
|
|
|
);
|
|
|
|
expect(album.toRemoteJson(), <String, dynamic>{
|
|
|
|
"version": Album.version,
|
|
|
|
"lastUpdated": "2020-01-02T03:04:05.678901Z",
|
|
|
|
"name": "",
|
|
|
|
"provider": <String, dynamic>{
|
|
|
|
"type": "static",
|
|
|
|
"content": <String, dynamic>{
|
|
|
|
"items": [],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"coverProvider": <String, dynamic>{
|
|
|
|
"type": "auto",
|
|
|
|
"content": <String, dynamic>{},
|
|
|
|
},
|
|
|
|
"sortProvider": <String, dynamic>{
|
|
|
|
"type": "null",
|
|
|
|
"content": <String, dynamic>{},
|
|
|
|
},
|
|
|
|
"shares": [
|
|
|
|
<String, dynamic>{
|
|
|
|
"userId": "admin",
|
|
|
|
},
|
|
|
|
],
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
void _toAppDbJsonShares() {
|
|
|
|
final album = Album(
|
|
|
|
lastUpdated: DateTime.utc(2020, 1, 2, 3, 4, 5, 678, 901),
|
|
|
|
name: "",
|
|
|
|
provider: AlbumStaticProvider(
|
|
|
|
items: [],
|
|
|
|
),
|
|
|
|
coverProvider: AlbumAutoCoverProvider(),
|
|
|
|
sortProvider: const AlbumNullSortProvider(),
|
|
|
|
shares: [AlbumShare(userId: "admin".toCi())],
|
|
|
|
);
|
|
|
|
expect(album.toAppDbJson(), <String, dynamic>{
|
|
|
|
"version": Album.version,
|
|
|
|
"lastUpdated": "2020-01-02T03:04:05.678901Z",
|
|
|
|
"name": "",
|
|
|
|
"provider": <String, dynamic>{
|
|
|
|
"type": "static",
|
|
|
|
"content": <String, dynamic>{
|
|
|
|
"items": [],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"coverProvider": <String, dynamic>{
|
|
|
|
"type": "auto",
|
|
|
|
"content": <String, dynamic>{},
|
|
|
|
},
|
|
|
|
"sortProvider": <String, dynamic>{
|
|
|
|
"type": "null",
|
|
|
|
"content": <String, dynamic>{},
|
|
|
|
},
|
|
|
|
"shares": [
|
|
|
|
<String, dynamic>{
|
|
|
|
"userId": "admin",
|
|
|
|
},
|
|
|
|
],
|
|
|
|
});
|
|
|
|
}
|
2021-11-18 09:43:14 +01:00
|
|
|
|
|
|
|
class _NullAlbumUpgraderFactory extends AlbumUpgraderFactory {
|
|
|
|
const _NullAlbumUpgraderFactory();
|
|
|
|
|
|
|
|
@override
|
|
|
|
buildV1() => null;
|
|
|
|
@override
|
|
|
|
buildV2() => null;
|
|
|
|
@override
|
|
|
|
buildV3() => null;
|
|
|
|
@override
|
|
|
|
buildV4() => null;
|
|
|
|
@override
|
|
|
|
buildV5() => null;
|
|
|
|
}
|