[Pkg-owncloud-commits] [owncloud] 210/394: add test case for increasesize
David Prévot
taffit at alioth.debian.org
Fri Nov 8 23:12:07 UTC 2013
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to annotated tag v4.5.10
in repository owncloud.
commit db946256f9949e20b95fd07daa95cb2e5f51fa2e
Author: Robin Appelman <icewind at owncloud.com>
Date: Wed Dec 12 16:32:12 2012 +0100
add test case for increasesize
---
tests/lib/filesystem.php | 76 +++++++++++++++++++++++++++++++++-------------
1 file changed, 55 insertions(+), 21 deletions(-)
diff --git a/tests/lib/filesystem.php b/tests/lib/filesystem.php
index 1fc2c27..c817f96 100644
--- a/tests/lib/filesystem.php
+++ b/tests/lib/filesystem.php
@@ -26,6 +26,8 @@ class Test_Filesystem extends UnitTestCase {
*/
private $tmpDirs;
+ private $user;
+
/**
* @return array
*/
@@ -45,6 +47,26 @@ class Test_Filesystem extends UnitTestCase {
OC_Filesystem::clearMounts();
}
+ private function setupTempMount() {
+ if(! $this->user){
+ if (OC_Filesystem::getView()) {
+ $user = OC_User::getUser();
+ } else {
+ $user = uniqid();
+ OC_Filesystem::init('/' . $user . '/files');
+ }
+ $this->user=$user;
+ }else{
+ $user=$this->user;
+ }
+
+ OC_Filesystem::mount('OC_Filestorage_Temporary', array(), '/');
+
+ $rootView = new OC_FilesystemView('');
+ $rootView->mkdir('/' . $user);
+ $rootView->mkdir('/' . $user . '/files');
+ }
+
public function testMount() {
OC_Filesystem::mount('OC_Filestorage_Local', self::getStorageData(), '/');
$this->assertEqual('/', OC_Filesystem::getMountPoint('/'));
@@ -88,18 +110,9 @@ class Test_Filesystem extends UnitTestCase {
);
$this->assertFalse($run);
- if (OC_Filesystem::getView()) {
- $user = OC_User::getUser();
- } else {
- $user = uniqid();
- OC_Filesystem::init('/' . $user . '/files');
- }
-
- OC_Filesystem::mount('OC_Filestorage_Temporary', array(), '/');
+ $this->setupTempMount();
$rootView = new OC_FilesystemView('');
- $rootView->mkdir('/' . $user);
- $rootView->mkdir('/' . $user . '/files');
$this->assertFalse($rootView->file_put_contents('/.htaccess', 'foo'));
$this->assertFalse(OC_Filesystem::file_put_contents('/.htaccess', 'foo'));
@@ -108,20 +121,10 @@ class Test_Filesystem extends UnitTestCase {
}
public function testHooks() {
- if(OC_Filesystem::getView()){
- $user = OC_User::getUser();
- }else{
- $user=uniqid();
- OC_Filesystem::init('/'.$user.'/files');
- }
OC_Hook::clear('OC_Filesystem');
OC_Hook::connect('OC_Filesystem', 'post_write', $this, 'dummyHook');
- OC_Filesystem::mount('OC_Filestorage_Temporary', array(), '/');
-
- $rootView=new OC_FilesystemView('');
- $rootView->mkdir('/'.$user);
- $rootView->mkdir('/'.$user.'/files');
+ $this->setupTempMount();
OC_Filesystem::file_put_contents('/foo', 'foo');
OC_Filesystem::mkdir('/bar');
@@ -137,4 +140,35 @@ class Test_Filesystem extends UnitTestCase {
$path = $arguments['path'];
$this->assertEqual($path, OC_Filesystem::normalizePath($path)); //the path passed to the hook should already be normalized
}
+
+ public function testSizeIncrease(){
+ OC_Hook::clear('OC_Filesystem');
+ OC_Hook::connect('OC_Filesystem', 'post_write','OC_FileCache_Update', 'fileSystemWatcherWrite');
+ OC_Hook::connect('OC_Filesystem', 'post_delete','OC_FileCache_Update', 'fileSystemWatcherDelete');
+ OC_Hook::connect('OC_Filesystem', 'post_rename','OC_FileCache_Update', 'fileSystemWatcherRename');
+
+ $this->setupTempMount();
+
+ // folder is empty
+ OC_FileCache::scan('');
+ $item = OC_FileCache_Cached::get('');
+ $this->assertEqual(0, $item['size']);
+
+ OC_Filesystem::file_put_contents('/foo', 'foo');
+
+ $item = OC_FileCache_Cached::get('');
+ $this->assertEqual(3, $item['size']);
+
+ OC_Filesystem::unlink('/foo');
+ $item = OC_FileCache_Cached::get('');
+ $this->assertEqual(0, $item['size']);
+
+ OC_Filesystem::mkdir('/bar');
+ OC_Filesystem::file_put_contents('/bar/foo', 'foo');
+
+ $item = OC_FileCache_Cached::get('');
+ $this->assertEqual(3, $item['size']);
+
+ OC_FileCache::delete('');
+ }
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git
More information about the Pkg-owncloud-commits
mailing list