nc-photos/test/entity/album_test.dart

947 lines
30 KiB
Dart
Raw Normal View History

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';
import 'package:test/test.dart';
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-07-23 22:05:57 +02:00
Album.fromJson(json,
upgraderV1: null, upgraderV2: null, upgraderV3: null),
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-07-07 20:40:43 +02:00
sortProvider: 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-07-23 22:05:57 +02:00
Album.fromJson(json,
upgraderV1: null, upgraderV2: null, upgraderV3: null),
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-07-07 20:40:43 +02:00
sortProvider: 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-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-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-07-23 22:05:57 +02:00
Album.fromJson(json,
upgraderV1: null, upgraderV2: null, upgraderV3: null),
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(
file: File(path: "remote.php/dav/files/admin/test1.jpg"),
),
AlbumFileItem(
file: File(path: "remote.php/dav/files/admin/test2.jpg"),
),
],
),
coverProvider: AlbumAutoCoverProvider(),
sortProvider: AlbumNullSortProvider(),
));
});
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-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-07-23 22:05:57 +02:00
Album.fromJson(json,
upgraderV1: null, upgraderV2: null, upgraderV3: null),
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(
text: "Testing",
),
],
),
coverProvider: AlbumAutoCoverProvider(),
sortProvider: AlbumNullSortProvider(),
));
});
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-07-23 22:05:57 +02:00
Album.fromJson(json,
upgraderV1: null, upgraderV2: null, upgraderV3: null),
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-07-07 20:40:43 +02:00
sortProvider: AlbumNullSortProvider(),
));
});
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-07-23 22:05:57 +02:00
Album.fromJson(json,
upgraderV1: null, upgraderV2: null, upgraderV3: null),
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(),
sortProvider: AlbumTimeSortProvider(
isAscending: true,
),
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>{
"path": "remote.php/dav/files/admin/test1.jpg",
2021-04-15 20:46:34 +02:00
},
};
expect(
2021-07-23 22:05:57 +02:00
Album.fromJson(json,
upgraderV1: null, upgraderV2: null, upgraderV3: null),
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-07-07 20:40:43 +02:00
sortProvider: AlbumNullSortProvider(),
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-07-07 20:40:43 +02:00
sortProvider: 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-07-07 20:40:43 +02:00
sortProvider: 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(
file: File(path: "remote.php/dav/files/admin/test1.jpg"),
),
AlbumFileItem(
file: File(path: "remote.php/dav/files/admin/test2.jpg"),
),
],
),
coverProvider: AlbumAutoCoverProvider(),
sortProvider: AlbumNullSortProvider(),
);
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-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-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(
text: "Testing",
),
2021-06-24 18:26:56 +02:00
],
2021-07-09 12:07:37 +02:00
),
coverProvider: AlbumAutoCoverProvider(),
sortProvider: AlbumNullSortProvider(),
);
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-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-07-07 20:40:43 +02:00
sortProvider: 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(),
sortProvider: AlbumTimeSortProvider(
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
});
});
});
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-07-07 20:40:43 +02:00
sortProvider: 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-07-07 20:40:43 +02:00
sortProvider: 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(
file: File(path: "remote.php/dav/files/admin/test1.jpg"),
),
AlbumFileItem(
file: File(path: "remote.php/dav/files/admin/test2.jpg"),
),
],
),
coverProvider: AlbumAutoCoverProvider(),
sortProvider: AlbumNullSortProvider(),
);
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-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-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(
text: "Testing",
),
2021-06-24 18:26:56 +02:00
],
2021-07-09 12:07:37 +02:00
),
coverProvider: AlbumAutoCoverProvider(),
sortProvider: AlbumNullSortProvider(),
);
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-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-07-07 20:40:43 +02:00
sortProvider: 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(),
sortProvider: AlbumTimeSortProvider(
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
});
});
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-07-07 20:40:43 +02:00
sortProvider: AlbumNullSortProvider(),
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>{
"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-04-15 20:46:34 +02:00
});
}