-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2562 from nextcloud/fix/nextcloud/webdav-subpath
- Loading branch information
Showing
3 changed files
with
271 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
266 changes: 266 additions & 0 deletions
266
packages/nextcloud/test/api/webdav/models/webdav_file_test.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,266 @@ | ||
import 'package:nextcloud/src/api/webdav/models/models.dart'; | ||
import 'package:test/expect.dart'; | ||
import 'package:test/scaffolding.dart'; | ||
|
||
void main() { | ||
test('props', () { | ||
expect( | ||
WebDavFile( | ||
response: const WebDavResponse( | ||
href: null, | ||
propstats: [ | ||
WebDavPropstat( | ||
status: 'HTTP/1.1 404 Not Found', | ||
prop: WebDavProp(ocSize: 1), | ||
), | ||
WebDavPropstat( | ||
status: 'HTTP/1.1 200 OK', | ||
prop: WebDavProp(ocSize: 2), | ||
), | ||
], | ||
), | ||
).props.ocSize, | ||
2, | ||
); | ||
}); | ||
|
||
group('path', () { | ||
group('Root', () { | ||
test('File', () { | ||
expect( | ||
WebDavFile( | ||
response: const WebDavResponse( | ||
href: '/remote.php/webdav/abc/def.txt', | ||
propstats: [], | ||
), | ||
).path, | ||
PathUri.parse('abc/def.txt'), | ||
); | ||
}); | ||
|
||
test('Directory', () { | ||
expect( | ||
WebDavFile( | ||
response: const WebDavResponse( | ||
href: '/remote.php/webdav/abc/def/', | ||
propstats: [], | ||
), | ||
).path, | ||
PathUri.parse('abc/def/'), | ||
); | ||
}); | ||
}); | ||
|
||
group('Subpath', () { | ||
test('File', () { | ||
expect( | ||
WebDavFile( | ||
response: const WebDavResponse( | ||
href: '/subpath/remote.php/webdav/abc/def.txt', | ||
propstats: [], | ||
), | ||
).path, | ||
PathUri.parse('abc/def.txt'), | ||
); | ||
}); | ||
|
||
test('Directory', () { | ||
expect( | ||
WebDavFile( | ||
response: const WebDavResponse( | ||
href: '/subpath/remote.php/webdav/abc/def/', | ||
propstats: [], | ||
), | ||
).path, | ||
PathUri.parse('abc/def/'), | ||
); | ||
}); | ||
}); | ||
}); | ||
|
||
group('name', () { | ||
test('File', () { | ||
expect( | ||
WebDavFile( | ||
response: const WebDavResponse( | ||
href: '/remote.php/webdav/abc/def.txt', | ||
propstats: [], | ||
), | ||
).name, | ||
'def.txt', | ||
); | ||
}); | ||
|
||
test('Directory', () { | ||
expect( | ||
WebDavFile( | ||
response: const WebDavResponse( | ||
href: '/remote.php/webdav/abc/def/', | ||
propstats: [], | ||
), | ||
).name, | ||
'def', | ||
); | ||
}); | ||
}); | ||
|
||
group('isHidden', () { | ||
group('From prop', () { | ||
test('File', () { | ||
expect( | ||
WebDavFile( | ||
response: const WebDavResponse( | ||
href: '/remote.php/webdav/abc/def.txt', | ||
propstats: [ | ||
WebDavPropstat( | ||
status: 'HTTP/1.1 200 OK', | ||
prop: WebDavProp( | ||
ncHidden: true, | ||
), | ||
), | ||
], | ||
), | ||
).isHidden, | ||
true, | ||
); | ||
}); | ||
|
||
test('Directory', () { | ||
expect( | ||
WebDavFile( | ||
response: const WebDavResponse( | ||
href: '/remote.php/webdav/abc/def/', | ||
propstats: [ | ||
WebDavPropstat( | ||
status: 'HTTP/1.1 200 OK', | ||
prop: WebDavProp( | ||
ncHidden: true, | ||
), | ||
), | ||
], | ||
), | ||
).isHidden, | ||
true, | ||
); | ||
}); | ||
}); | ||
|
||
group('From path', () { | ||
test('File', () { | ||
expect( | ||
WebDavFile( | ||
response: const WebDavResponse( | ||
href: '/remote.php/webdav/abc/.def.txt', | ||
propstats: [ | ||
WebDavPropstat( | ||
status: 'HTTP/1.1 200 OK', | ||
prop: WebDavProp(), | ||
), | ||
], | ||
), | ||
).isHidden, | ||
true, | ||
); | ||
}); | ||
|
||
test('Directory', () { | ||
expect( | ||
WebDavFile( | ||
response: const WebDavResponse( | ||
href: '/remote.php/webdav/abc/.def/', | ||
propstats: [ | ||
WebDavPropstat( | ||
status: 'HTTP/1.1 200 OK', | ||
prop: WebDavProp(), | ||
), | ||
], | ||
), | ||
).isHidden, | ||
true, | ||
); | ||
}); | ||
}); | ||
}); | ||
|
||
group('isDirectory', () { | ||
group('From prop', () { | ||
test('File', () { | ||
expect( | ||
WebDavFile( | ||
response: const WebDavResponse( | ||
href: '/remote.php/webdav/abc/def.txt', | ||
propstats: [ | ||
WebDavPropstat( | ||
status: 'HTTP/1.1 200 OK', | ||
prop: WebDavProp( | ||
davResourcetype: WebDavResourcetype( | ||
collection: null, | ||
), | ||
), | ||
), | ||
], | ||
), | ||
).isDirectory, | ||
false, | ||
); | ||
}); | ||
|
||
test('Directory', () { | ||
expect( | ||
WebDavFile( | ||
response: const WebDavResponse( | ||
href: '/remote.php/webdav/abc/def/', | ||
propstats: [ | ||
WebDavPropstat( | ||
status: 'HTTP/1.1 200 OK', | ||
prop: WebDavProp( | ||
davResourcetype: WebDavResourcetype( | ||
collection: [], | ||
), | ||
), | ||
), | ||
], | ||
), | ||
).isDirectory, | ||
true, | ||
); | ||
}); | ||
}); | ||
|
||
group('From path', () { | ||
test('File', () { | ||
expect( | ||
WebDavFile( | ||
response: const WebDavResponse( | ||
href: '/remote.php/webdav/abc/def.txt', | ||
propstats: [ | ||
WebDavPropstat( | ||
status: 'HTTP/1.1 200 OK', | ||
prop: WebDavProp(), | ||
), | ||
], | ||
), | ||
).isDirectory, | ||
false, | ||
); | ||
}); | ||
|
||
test('Directory', () { | ||
expect( | ||
WebDavFile( | ||
response: const WebDavResponse( | ||
href: '/remote.php/webdav/abc/def/', | ||
propstats: [ | ||
WebDavPropstat( | ||
status: 'HTTP/1.1 200 OK', | ||
prop: WebDavProp(), | ||
), | ||
], | ||
), | ||
).isDirectory, | ||
true, | ||
); | ||
}); | ||
}); | ||
}); | ||
} |