From 275603d88a01c4149514eb6c8953dd27782d08b7 Mon Sep 17 00:00:00 2001 From: Ming Ming Date: Wed, 26 May 2021 03:55:25 +0800 Subject: [PATCH] Fix incorrect test cases Path never begins with / in practice --- test/entity/album_test.dart | 52 +++++++++--------- test/entity/file_test.dart | 102 ++++++++++++++++++------------------ 2 files changed, 77 insertions(+), 77 deletions(-) diff --git a/test/entity/album_test.dart b/test/entity/album_test.dart index 210fea35..0558c111 100644 --- a/test/entity/album_test.dart +++ b/test/entity/album_test.dart @@ -46,7 +46,7 @@ void main() { "type": "file", "content": { "file": { - "path": "/remote.php/dav/files/admin/test1.jpg", + "path": "remote.php/dav/files/admin/test1.jpg", }, }, }, @@ -54,7 +54,7 @@ void main() { "type": "file", "content": { "file": { - "path": "/remote.php/dav/files/admin/test2.jpg", + "path": "remote.php/dav/files/admin/test2.jpg", }, }, }, @@ -67,10 +67,10 @@ void main() { name: "", items: [ AlbumFileItem( - file: File(path: "/remote.php/dav/files/admin/test1.jpg"), + file: File(path: "remote.php/dav/files/admin/test1.jpg"), ), AlbumFileItem( - file: File(path: "/remote.php/dav/files/admin/test2.jpg"), + file: File(path: "remote.php/dav/files/admin/test2.jpg"), ), ], )); @@ -82,7 +82,7 @@ void main() { "lastUpdated": "2020-01-02T03:04:05.678901Z", "items": [], "albumFile": { - "path": "/remote.php/dav/files/admin/test1.jpg", + "path": "remote.php/dav/files/admin/test1.jpg", }, }; expect( @@ -91,7 +91,7 @@ void main() { lastUpdated: DateTime.utc(2020, 1, 2, 3, 4, 5, 678, 901), name: "", items: [], - albumFile: File(path: "/remote.php/dav/files/admin/test1.jpg"), + albumFile: File(path: "remote.php/dav/files/admin/test1.jpg"), )); }); }); @@ -131,10 +131,10 @@ void main() { name: "", items: [ AlbumFileItem( - file: File(path: "/remote.php/dav/files/admin/test1.jpg"), + file: File(path: "remote.php/dav/files/admin/test1.jpg"), ), AlbumFileItem( - file: File(path: "/remote.php/dav/files/admin/test2.jpg"), + file: File(path: "remote.php/dav/files/admin/test2.jpg"), ), ], ); @@ -147,7 +147,7 @@ void main() { "type": "file", "content": { "file": { - "path": "/remote.php/dav/files/admin/test1.jpg", + "path": "remote.php/dav/files/admin/test1.jpg", }, }, }, @@ -155,7 +155,7 @@ void main() { "type": "file", "content": { "file": { - "path": "/remote.php/dav/files/admin/test2.jpg", + "path": "remote.php/dav/files/admin/test2.jpg", }, }, }, @@ -199,10 +199,10 @@ void main() { name: "", items: [ AlbumFileItem( - file: File(path: "/remote.php/dav/files/admin/test1.jpg"), + file: File(path: "remote.php/dav/files/admin/test1.jpg"), ), AlbumFileItem( - file: File(path: "/remote.php/dav/files/admin/test2.jpg"), + file: File(path: "remote.php/dav/files/admin/test2.jpg"), ), ], ); @@ -215,7 +215,7 @@ void main() { "type": "file", "content": { "file": { - "path": "/remote.php/dav/files/admin/test1.jpg", + "path": "remote.php/dav/files/admin/test1.jpg", }, }, }, @@ -223,7 +223,7 @@ void main() { "type": "file", "content": { "file": { - "path": "/remote.php/dav/files/admin/test2.jpg", + "path": "remote.php/dav/files/admin/test2.jpg", }, }, }, @@ -236,7 +236,7 @@ void main() { lastUpdated: DateTime.utc(2020, 1, 2, 3, 4, 5, 678, 901), name: "", items: [], - albumFile: File(path: "/remote.php/dav/files/admin/test1.jpg"), + albumFile: File(path: "remote.php/dav/files/admin/test1.jpg"), ); expect(album.toAppDbJson(), { "version": Album.version, @@ -244,7 +244,7 @@ void main() { "name": "", "items": [], "albumFile": { - "path": "/remote.php/dav/files/admin/test1.jpg", + "path": "remote.php/dav/files/admin/test1.jpg", }, }); }); @@ -258,13 +258,13 @@ void main() { name: "album", items: [ AlbumFileItem( - file: File(path: "/remote.php/dav/files/admin/test1.jpg"), + file: File(path: "remote.php/dav/files/admin/test1.jpg"), ), AlbumFileItem( - file: File(path: "/remote.php/dav/files/admin/test2.jpg"), + file: File(path: "remote.php/dav/files/admin/test2.jpg"), ), ], - albumFile: File(path: "/remote.php/dav/files/admin/test1.jpg"), + albumFile: File(path: "remote.php/dav/files/admin/test1.jpg"), ); expect( album, @@ -272,7 +272,7 @@ void main() { lastUpdated: DateTime.utc(2020, 1, 2, 3, 4, 5, 678, 901), name: "album", items: [], - albumFile: File(path: "/remote.php/dav/files/admin/test1.jpg"), + albumFile: File(path: "remote.php/dav/files/admin/test1.jpg"), )); }); @@ -283,13 +283,13 @@ void main() { name: "album", items: [ AlbumFileItem( - file: File(path: "/remote.php/dav/files/admin/test1.jpg"), + file: File(path: "remote.php/dav/files/admin/test1.jpg"), ), AlbumFileItem( - file: File(path: "/remote.php/dav/files/admin/test2.jpg"), + file: File(path: "remote.php/dav/files/admin/test2.jpg"), ), ], - albumFile: File(path: "/remote.php/dav/files/admin/test1.jpg"), + albumFile: File(path: "remote.php/dav/files/admin/test1.jpg"), ); expect( album, @@ -298,13 +298,13 @@ void main() { name: "album", items: [ AlbumFileItem( - file: File(path: "/remote.php/dav/files/admin/test1.jpg"), + file: File(path: "remote.php/dav/files/admin/test1.jpg"), ), AlbumFileItem( - file: File(path: "/remote.php/dav/files/admin/test2.jpg"), + file: File(path: "remote.php/dav/files/admin/test2.jpg"), ), ], - albumFile: File(path: "/remote.php/dav/files/admin/test1.jpg"), + albumFile: File(path: "remote.php/dav/files/admin/test1.jpg"), )); }); }); diff --git a/test/entity/file_test.dart b/test/entity/file_test.dart index 34eb4d98..f1d2f317 100644 --- a/test/entity/file_test.dart +++ b/test/entity/file_test.dart @@ -7,11 +7,11 @@ void main() { group("compareFileDateTimeDescending", () { test("lastModified a>b", () { final a = File( - path: "/remote.php/dav/files/admin/test1.jpg", + path: "remote.php/dav/files/admin/test1.jpg", lastModified: DateTime.utc(2021), ); final b = File( - path: "/remote.php/dav/files/admin/test2.jpg", + path: "remote.php/dav/files/admin/test2.jpg", lastModified: DateTime.utc(2020), ); expect(compareFileDateTimeDescending(a, b), lessThan(0)); @@ -19,11 +19,11 @@ void main() { test("lastModified ab", () { final a = File( - path: "/remote.php/dav/files/admin/test1.jpg", + path: "remote.php/dav/files/admin/test1.jpg", metadata: Metadata( exif: Exif({ "DateTimeOriginal": "2021:01:02 03:04:05", @@ -51,7 +51,7 @@ void main() { ), ); final b = File( - path: "/remote.php/dav/files/admin/test2.jpg", + path: "remote.php/dav/files/admin/test2.jpg", metadata: Metadata( exif: Exif({ "DateTimeOriginal": "2020:01:02 03:04:05", @@ -63,7 +63,7 @@ void main() { test("exif a{ - "path": "/remote.php/dav/files/admin/test.jpg", + "path": "remote.php/dav/files/admin/test.jpg", }; final file = File.fromJson(json); - expect(file, File(path: "/remote.php/dav/files/admin/test.jpg")); + expect(file, File(path: "remote.php/dav/files/admin/test.jpg")); }); test("contentLength", () { @@ -435,95 +435,95 @@ void main() { group("toJson", () { test("path", () { - final file = File(path: "/remote.php/dav/files/admin/test.jpg"); + final file = File(path: "remote.php/dav/files/admin/test.jpg"); expect(file.toJson(), { - "path": "/remote.php/dav/files/admin/test.jpg", + "path": "remote.php/dav/files/admin/test.jpg", }); }); test("contentLength", () { final file = File( - path: "/remote.php/dav/files/admin/test.jpg", contentLength: 123); + path: "remote.php/dav/files/admin/test.jpg", contentLength: 123); expect(file.toJson(), { - "path": "/remote.php/dav/files/admin/test.jpg", + "path": "remote.php/dav/files/admin/test.jpg", "contentLength": 123, }); }); test("contentType", () { final file = File( - path: "/remote.php/dav/files/admin/test.jpg", + path: "remote.php/dav/files/admin/test.jpg", contentType: "image/jpeg"); expect(file.toJson(), { - "path": "/remote.php/dav/files/admin/test.jpg", + "path": "remote.php/dav/files/admin/test.jpg", "contentType": "image/jpeg", }); }); test("etag", () { final file = File( - path: "/remote.php/dav/files/admin/test.jpg", + path: "remote.php/dav/files/admin/test.jpg", etag: "8a3e0799b6f0711c23cc2d93950eceb5"); expect(file.toJson(), { - "path": "/remote.php/dav/files/admin/test.jpg", + "path": "remote.php/dav/files/admin/test.jpg", "etag": "8a3e0799b6f0711c23cc2d93950eceb5", }); }); test("lastModified", () { final file = File( - path: "/remote.php/dav/files/admin/test.jpg", + path: "remote.php/dav/files/admin/test.jpg", lastModified: DateTime.utc(2020, 1, 2, 3, 4, 5, 678, 901)); expect(file.toJson(), { - "path": "/remote.php/dav/files/admin/test.jpg", + "path": "remote.php/dav/files/admin/test.jpg", "lastModified": "2020-01-02T03:04:05.678901Z", }); }); test("isCollection", () { final file = File( - path: "/remote.php/dav/files/admin/test.jpg", isCollection: true); + path: "remote.php/dav/files/admin/test.jpg", isCollection: true); expect(file.toJson(), { - "path": "/remote.php/dav/files/admin/test.jpg", + "path": "remote.php/dav/files/admin/test.jpg", "isCollection": true, }); }); test("usedBytes", () { final file = File( - path: "/remote.php/dav/files/admin/test.jpg", usedBytes: 123456); + path: "remote.php/dav/files/admin/test.jpg", usedBytes: 123456); expect(file.toJson(), { - "path": "/remote.php/dav/files/admin/test.jpg", + "path": "remote.php/dav/files/admin/test.jpg", "usedBytes": 123456, }); }); test("hasPreview", () { final file = File( - path: "/remote.php/dav/files/admin/test.jpg", hasPreview: true); + path: "remote.php/dav/files/admin/test.jpg", hasPreview: true); expect(file.toJson(), { - "path": "/remote.php/dav/files/admin/test.jpg", + "path": "remote.php/dav/files/admin/test.jpg", "hasPreview": true, }); }); test("fileId", () { final file = - File(path: "/remote.php/dav/files/admin/test.jpg", fileId: 123); + File(path: "remote.php/dav/files/admin/test.jpg", fileId: 123); expect(file.toJson(), { - "path": "/remote.php/dav/files/admin/test.jpg", + "path": "remote.php/dav/files/admin/test.jpg", "fileId": 123, }); }); test("metadata", () { final file = File( - path: "/remote.php/dav/files/admin/test.jpg", + path: "remote.php/dav/files/admin/test.jpg", metadata: Metadata( lastUpdated: DateTime.utc(2020, 1, 2, 3, 4, 5, 678, 901), )); expect(file.toJson(), { - "path": "/remote.php/dav/files/admin/test.jpg", + "path": "remote.php/dav/files/admin/test.jpg", "metadata": { "version": Metadata.version, "lastUpdated": "2020-01-02T03:04:05.678901Z", @@ -534,7 +534,7 @@ void main() { group("copyWith", () { final src = File( - path: "/remote.php/dav/files/admin/test.jpg", + path: "remote.php/dav/files/admin/test.jpg", contentLength: 123, contentType: "image/jpeg", etag: "8a3e0799b6f0711c23cc2d93950eceb5", @@ -547,11 +547,11 @@ void main() { ); test("path", () { - final file = src.copyWith(path: "/remote.php/dav/files/admin/test.png"); + final file = src.copyWith(path: "remote.php/dav/files/admin/test.png"); expect( file, File( - path: "/remote.php/dav/files/admin/test.png", + path: "remote.php/dav/files/admin/test.png", contentLength: 123, contentType: "image/jpeg", etag: "8a3e0799b6f0711c23cc2d93950eceb5", @@ -568,7 +568,7 @@ void main() { expect( file, File( - path: "/remote.php/dav/files/admin/test.jpg", + path: "remote.php/dav/files/admin/test.jpg", contentLength: 321, contentType: "image/jpeg", etag: "8a3e0799b6f0711c23cc2d93950eceb5", @@ -585,7 +585,7 @@ void main() { expect( file, File( - path: "/remote.php/dav/files/admin/test.jpg", + path: "remote.php/dav/files/admin/test.jpg", contentLength: 123, contentType: "image/png", etag: "8a3e0799b6f0711c23cc2d93950eceb5", @@ -602,7 +602,7 @@ void main() { expect( file, File( - path: "/remote.php/dav/files/admin/test.jpg", + path: "remote.php/dav/files/admin/test.jpg", contentLength: 123, contentType: "image/jpeg", etag: "000", @@ -620,7 +620,7 @@ void main() { expect( file, File( - path: "/remote.php/dav/files/admin/test.jpg", + path: "remote.php/dav/files/admin/test.jpg", contentLength: 123, contentType: "image/jpeg", etag: "8a3e0799b6f0711c23cc2d93950eceb5", @@ -637,7 +637,7 @@ void main() { expect( file, File( - path: "/remote.php/dav/files/admin/test.jpg", + path: "remote.php/dav/files/admin/test.jpg", contentLength: 123, contentType: "image/jpeg", etag: "8a3e0799b6f0711c23cc2d93950eceb5", @@ -654,7 +654,7 @@ void main() { expect( file, File( - path: "/remote.php/dav/files/admin/test.jpg", + path: "remote.php/dav/files/admin/test.jpg", contentLength: 123, contentType: "image/jpeg", etag: "8a3e0799b6f0711c23cc2d93950eceb5", @@ -671,7 +671,7 @@ void main() { expect( file, File( - path: "/remote.php/dav/files/admin/test.jpg", + path: "remote.php/dav/files/admin/test.jpg", contentLength: 123, contentType: "image/jpeg", etag: "8a3e0799b6f0711c23cc2d93950eceb5", @@ -688,7 +688,7 @@ void main() { expect( file, File( - path: "/remote.php/dav/files/admin/test.jpg", + path: "remote.php/dav/files/admin/test.jpg", contentLength: 123, contentType: "image/jpeg", etag: "8a3e0799b6f0711c23cc2d93950eceb5", @@ -706,7 +706,7 @@ void main() { expect( file, File( - path: "/remote.php/dav/files/admin/test.jpg", + path: "remote.php/dav/files/admin/test.jpg", contentLength: 123, contentType: "image/jpeg", etag: "8a3e0799b6f0711c23cc2d93950eceb5", @@ -721,7 +721,7 @@ void main() { test("clear metadata", () { final src = File( - path: "/remote.php/dav/files/admin/test.jpg", + path: "remote.php/dav/files/admin/test.jpg", contentLength: 123, contentType: "image/jpeg", etag: "8a3e0799b6f0711c23cc2d93950eceb5", @@ -736,7 +736,7 @@ void main() { expect( file, File( - path: "/remote.php/dav/files/admin/test.jpg", + path: "remote.php/dav/files/admin/test.jpg", contentLength: 123, contentType: "image/jpeg", etag: "8a3e0799b6f0711c23cc2d93950eceb5", @@ -751,12 +751,12 @@ void main() { group("strippedPath", () { test("file", () { - final file = File(path: "/remote.php/dav/files/admin/test.jpg"); - expect(file.strippedPath, "admin/test.jpg"); + final file = File(path: "remote.php/dav/files/admin/test.jpg"); + expect(file.strippedPath, "test.jpg"); }); test("root dir", () { - final file = File(path: "/remote.php/dav/files/admin"); + final file = File(path: "remote.php/dav/files/admin"); expect(file.strippedPath, "."); }); });