|
|
@ -9,18 +9,25 @@ import 'package:universal_io/io.dart'; |
|
|
|
import 'helper.dart'; |
|
|
|
import 'helper.dart'; |
|
|
|
|
|
|
|
|
|
|
|
void main() { |
|
|
|
void main() { |
|
|
|
test('constructUri', () { |
|
|
|
group('constructUri', () { |
|
|
|
var baseURL = Uri.parse('http://cloud.example.com'); |
|
|
|
for (final values in [ |
|
|
|
expect(WebDavClient.constructUri(baseURL).toString(), '$baseURL$webdavBasePath'); |
|
|
|
('http://cloud.example.com', 'http://cloud.example.com'), |
|
|
|
expect(WebDavClient.constructUri(baseURL, Uri(path: '/')).toString(), '$baseURL$webdavBasePath'); |
|
|
|
('http://cloud.example.com/', 'http://cloud.example.com'), |
|
|
|
expect(WebDavClient.constructUri(baseURL, Uri(path: 'test')).toString(), '$baseURL$webdavBasePath/test'); |
|
|
|
('http://cloud.example.com/subdir', 'http://cloud.example.com/subdir'), |
|
|
|
|
|
|
|
('http://cloud.example.com/subdir/', 'http://cloud.example.com/subdir'), |
|
|
|
baseURL = Uri.parse('http://cloud.example.com/subdir'); |
|
|
|
]) { |
|
|
|
expect(WebDavClient.constructUri(baseURL, Uri(path: 'test')).toString(), '$baseURL$webdavBasePath/test'); |
|
|
|
final baseURL = Uri.parse(values.$1); |
|
|
|
|
|
|
|
final sanitizedBaseURL = Uri.parse(values.$2); |
|
|
|
expect(() => WebDavClient.constructUri(baseURL, Uri(path: '/test')), throwsA(isA<AssertionError>())); |
|
|
|
|
|
|
|
baseURL = Uri.parse('http://cloud.example.com/'); |
|
|
|
test('$baseURL', () { |
|
|
|
expect(() => WebDavClient.constructUri(baseURL), throwsA(isA<AssertionError>())); |
|
|
|
expect(WebDavClient.constructUri(baseURL).toString(), '$sanitizedBaseURL$webdavBase'); |
|
|
|
|
|
|
|
expect(WebDavClient.constructUri(baseURL, Uri(path: '/')).toString(), '$sanitizedBaseURL$webdavBase'); |
|
|
|
|
|
|
|
expect(WebDavClient.constructUri(baseURL, Uri(path: 'test')).toString(), '$sanitizedBaseURL$webdavBase/test'); |
|
|
|
|
|
|
|
expect(WebDavClient.constructUri(baseURL, Uri(path: 'test/')).toString(), '$sanitizedBaseURL$webdavBase/test'); |
|
|
|
|
|
|
|
expect(WebDavClient.constructUri(baseURL, Uri(path: '/test')).toString(), '$sanitizedBaseURL$webdavBase/test'); |
|
|
|
|
|
|
|
expect(WebDavClient.constructUri(baseURL, Uri(path: '/test/')).toString(), '$sanitizedBaseURL$webdavBase/test'); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
group( |
|
|
|
group( |
|
|
@ -100,7 +107,7 @@ void main() { |
|
|
|
.toWebDavFiles() |
|
|
|
.toWebDavFiles() |
|
|
|
.single; |
|
|
|
.single; |
|
|
|
|
|
|
|
|
|
|
|
expect(response.path, '/Nextcloud.png'); |
|
|
|
expect(response.path, Uri(path: 'Nextcloud.png')); |
|
|
|
expect(response.id, isNotEmpty); |
|
|
|
expect(response.id, isNotEmpty); |
|
|
|
expect(response.fileId, isNotEmpty); |
|
|
|
expect(response.fileId, isNotEmpty); |
|
|
|
expect(response.isCollection, isFalse); |
|
|
|
expect(response.isCollection, isFalse); |
|
|
@ -165,7 +172,7 @@ void main() { |
|
|
|
.toWebDavFiles() |
|
|
|
.toWebDavFiles() |
|
|
|
.single; |
|
|
|
.single; |
|
|
|
|
|
|
|
|
|
|
|
expect(response.path, '/test/'); |
|
|
|
expect(response.path, Uri(path: 'test/')); |
|
|
|
expect(response.isCollection, isTrue); |
|
|
|
expect(response.isCollection, isTrue); |
|
|
|
expect(response.mimeType, isNull); |
|
|
|
expect(response.mimeType, isNull); |
|
|
|
expect(response.size, data.lengthInBytes); |
|
|
|
expect(response.size, data.lengthInBytes); |
|
|
|