Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
jio
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Alexandra Rogova
jio
Commits
e6ee0d6d
Commit
e6ee0d6d
authored
Mar 02, 2018
by
Vincent Bechu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[cloudoostorage] add test on repair
parent
0bce7aa0
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
150 additions
and
21 deletions
+150
-21
src/jio.storage/cloudoostorage.js
src/jio.storage/cloudoostorage.js
+9
-10
test/jio.storage/cloudoostorage.tests.js
test/jio.storage/cloudoostorage.tests.js
+141
-11
No files found.
src/jio.storage/cloudoostorage.js
View file @
e6ee0d6d
...
@@ -72,13 +72,12 @@
...
@@ -72,13 +72,12 @@
});
});
})
})
.
push
(
function
(
result
)
{
.
push
(
function
(
result
)
{
var
data
=
parser
.
parseFromString
(
var
data
_list
=
parser
.
parseFromString
(
result
.
target
.
responseText
,
result
.
target
.
responseText
,
"
application/xml
"
"
application/xml
"
),
).
getElementsByTagName
(
'
string
'
);
content
=
data
.
getElementsByTagName
(
'
string
'
);
if
(
data_list
.
length
)
{
if
(
content
.
length
>
0
)
{
return
b64toBlob
(
data_list
[
0
].
textContent
,
to
);
return
b64toBlob
(
content
[
0
].
textContent
,
to
);
}
}
throw
new
jIO
.
util
.
jIOError
(
'
conversion failed
'
,
404
);
throw
new
jIO
.
util
.
jIOError
(
'
conversion failed
'
,
404
);
});
});
...
@@ -253,18 +252,18 @@
...
@@ -253,18 +252,18 @@
var
storage
=
this
;
var
storage
=
this
;
return
this
.
_sub_storage
.
repair
.
apply
(
this
.
_sub_storage
,
arguments
)
return
this
.
_sub_storage
.
repair
.
apply
(
this
.
_sub_storage
,
arguments
)
.
push
(
function
()
{
.
push
(
function
()
{
return
storage
.
allDocs
({
return
storage
.
_sub_storage
.
allDocs
({
query
:
'
portal_type: "Conversion Info"
'
,
query
:
'
portal_type: "Conversion Info"
'
,
select_list
:
[
'
convert_
lis
t
'
,
'
doc_id
'
,
'
attachment_id
'
]
select_list
:
[
'
convert_
dic
t
'
,
'
doc_id
'
,
'
attachment_id
'
]
});
});
})
})
.
push
(
function
(
result
)
{
.
push
(
function
(
result
)
{
var
i
,
promise_list
=
[],
format
,
value
;
var
i
,
promise_list
=
[],
format
,
value
;
for
(
i
=
0
;
i
<
result
.
data
.
total_rows
;
i
+=
1
)
{
for
(
i
=
0
;
i
<
result
.
data
.
total_rows
;
i
+=
1
)
{
value
=
result
.
data
.
rows
[
i
].
value
;
value
=
result
.
data
.
rows
[
i
].
value
;
for
(
format
in
value
.
convert_
lis
t
)
{
for
(
format
in
value
.
convert_
dic
t
)
{
if
(
value
.
convert_
lis
t
.
hasOwnProperty
(
format
)
&&
if
(
value
.
convert_
dic
t
.
hasOwnProperty
(
format
)
&&
value
.
convert_
lis
t
[
format
]
===
false
)
{
value
.
convert_
dic
t
[
format
]
===
false
)
{
promise_list
.
push
(
convertAttachment
(
promise_list
.
push
(
convertAttachment
(
storage
,
storage
,
value
.
doc_id
,
value
.
doc_id
,
...
...
test/jio.storage/cloudoostorage.tests.js
View file @
e6ee0d6d
...
@@ -22,7 +22,7 @@
...
@@ -22,7 +22,7 @@
jIO
.
addStorage
(
'
cloudoostorage200
'
,
Storage200
);
jIO
.
addStorage
(
'
cloudoostorage200
'
,
Storage200
);
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
// C
rypt
Storage.constructor
// C
loudoo
Storage.constructor
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
module
(
"
cloudooStorage.constructor
"
);
module
(
"
cloudooStorage.constructor
"
);
...
@@ -39,7 +39,7 @@
...
@@ -39,7 +39,7 @@
equal
(
jio
.
__storage
.
_sub_storage
.
__type
,
"
cloudoostorage200
"
);
equal
(
jio
.
__storage
.
_sub_storage
.
__type
,
"
cloudoostorage200
"
);
});
});
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
// C
rypt
Storage.get
// C
loudoo
Storage.get
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
module
(
"
cloudooStorage.get
"
);
module
(
"
cloudooStorage.get
"
);
test
(
"
get called substorage get
"
,
function
()
{
test
(
"
get called substorage get
"
,
function
()
{
...
@@ -73,7 +73,7 @@
...
@@ -73,7 +73,7 @@
});
});
});
});
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
// C
rypt
Storage.post
// C
loudoo
Storage.post
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
module
(
"
cloudooStorage.post
"
);
module
(
"
cloudooStorage.post
"
);
test
(
"
post called substorage post
"
,
function
()
{
test
(
"
post called substorage post
"
,
function
()
{
...
@@ -105,7 +105,7 @@
...
@@ -105,7 +105,7 @@
});
});
});
});
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
// C
rypt
Storage.put
// C
loudoo
Storage.put
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
module
(
"
cloudooStorage.put
"
);
module
(
"
cloudooStorage.put
"
);
test
(
"
put called substorage put
"
,
function
()
{
test
(
"
put called substorage put
"
,
function
()
{
...
@@ -138,7 +138,7 @@
...
@@ -138,7 +138,7 @@
});
});
});
});
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
// C
rypt
Storage.remove
// C
loudoo
Storage.remove
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
module
(
"
cloudooStorage.remove
"
);
module
(
"
cloudooStorage.remove
"
);
test
(
"
remove called substorage remove
"
,
function
()
{
test
(
"
remove called substorage remove
"
,
function
()
{
...
@@ -170,7 +170,7 @@
...
@@ -170,7 +170,7 @@
});
});
});
});
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
// C
rypt
Storage.hasCapacity
// C
loudoo
Storage.hasCapacity
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
module
(
"
cloudooStorage.hasCapacity
"
);
module
(
"
cloudooStorage.hasCapacity
"
);
test
(
"
hasCapacity return substorage value
"
,
function
()
{
test
(
"
hasCapacity return substorage value
"
,
function
()
{
...
@@ -199,7 +199,7 @@
...
@@ -199,7 +199,7 @@
);
);
});
});
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
// C
rypt
Storage.buildQuery
// C
loudoo
Storage.buildQuery
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
module
(
"
cloudooStorage.buildQuery
"
);
module
(
"
cloudooStorage.buildQuery
"
);
...
@@ -253,7 +253,7 @@
...
@@ -253,7 +253,7 @@
});
});
});
});
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
// C
rypt
Storage.removeAttachment
// C
loudoo
Storage.removeAttachment
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
module
(
"
cloudooStorage.removeAttachment
"
);
module
(
"
cloudooStorage.removeAttachment
"
);
test
(
"
removeAttachment called substorage removeAttachment
"
,
function
()
{
test
(
"
removeAttachment called substorage removeAttachment
"
,
function
()
{
...
@@ -299,7 +299,7 @@
...
@@ -299,7 +299,7 @@
});
});
});
});
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
// C
rypt
Storage.allAttachments
// C
loudoo
Storage.allAttachments
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
module
(
"
cloudooStorage.allAttachments
"
);
module
(
"
cloudooStorage.allAttachments
"
);
test
(
"
allAttachments called substorage allAttachments
"
,
function
()
{
test
(
"
allAttachments called substorage allAttachments
"
,
function
()
{
...
@@ -333,7 +333,7 @@
...
@@ -333,7 +333,7 @@
});
});
});
});
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
// C
rypt
Storage.getAttachment
// C
loudoo
Storage.getAttachment
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
module
(
"
cloudooStorage.getAttachment
"
,
{
module
(
"
cloudooStorage.getAttachment
"
,
{
...
@@ -508,7 +508,7 @@
...
@@ -508,7 +508,7 @@
});
});
});
});
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
// C
rypt
Storage.putAttachment
// C
loudoo
Storage.putAttachment
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
module
(
"
cloudooStorage.putAttachment
"
);
module
(
"
cloudooStorage.putAttachment
"
);
test
(
"
putAttachment called substorage putAttachment
"
,
function
()
{
test
(
"
putAttachment called substorage putAttachment
"
,
function
()
{
...
@@ -563,4 +563,134 @@
...
@@ -563,4 +563,134 @@
});
});
});
});
/////////////////////////////////////////////////////////////////
// CloudooStorage.repair
/////////////////////////////////////////////////////////////////
module
(
"
cloudooStorage.repair
"
,
{
setup
:
function
()
{
this
.
server
=
sinon
.
fakeServer
.
create
();
this
.
server
.
autoRespond
=
true
;
this
.
server
.
autoRespondAfter
=
5
;
this
.
jio
=
jIO
.
createJIO
({
type
:
"
cloudoo
"
,
url
:
cloudoo_url
,
sub_storage
:
{
type
:
"
cloudoostorage200
"
}
});
},
teardown
:
function
()
{
this
.
server
.
restore
();
delete
this
.
server
;
}
});
test
(
"
repair convert attachment
"
,
function
()
{
stop
();
expect
(
14
);
var
blob
=
new
Blob
([
"
documentauformatdocy
"
]),
server
=
this
.
server
,
blob_convert
=
new
Blob
([
"
documentauformatdocx
"
],
{
type
:
"
docx
"
});
this
.
server
.
respondWith
(
"
POST
"
,
cloudoo_url
,
[
200
,
{
"
Content-Type
"
:
"
text/xml
"
},
'
<?xml version="1.0" encoding="UTF-8"?>
'
+
'
<string>ZG9jdW1lbnRhdWZvcm1hdGRvY3g=</string>
'
]);
Storage200
.
prototype
.
repair
=
function
()
{
return
"
OK
"
;
};
Storage200
.
prototype
.
hasCapacity
=
function
()
{
return
true
;
};
Storage200
.
prototype
.
get
=
function
(
id
)
{
equal
(
id
,
'
cloudoo/bar/data
'
,
'
check get 200 called
'
);
return
{
"
attachment_id
"
:
"
data
"
,
"
convert_dict
"
:
{
"
docx
"
:
false
},
"
doc_id
"
:
"
bar
"
,
"
format
"
:
"
docy
"
,
"
portal_type
"
:
"
Conversion Info
"
};
};
Storage200
.
prototype
.
put
=
function
(
id
,
doc
)
{
equal
(
id
,
"
cloudoo/bar/data
"
,
"
check put 200 called
"
);
deepEqual
(
doc
,
{
"
attachment_id
"
:
"
data
"
,
"
convert_dict
"
:
{
"
docx
"
:
true
},
"
doc_id
"
:
"
bar
"
,
"
format
"
:
"
docy
"
,
"
portal_type
"
:
"
Conversion Info
"
},
"
check put 200 called
"
);
};
Storage200
.
prototype
.
getAttachment
=
function
(
id
,
att_id
)
{
equal
(
id
,
'
bar
'
,
"
check getAttachment 200 called
"
);
equal
(
att_id
,
'
data
'
,
"
check getAttachment 200 called
"
);
return
blob
;
};
Storage200
.
prototype
.
putAttachment
=
function
(
id
,
att_id
,
result
)
{
equal
(
id
,
'
bar
'
,
'
check putAttachment 200 called
'
);
equal
(
att_id
,
'
data?docx
'
,
"
check puttAttachment 200 called
"
);
deepEqual
(
result
,
blob_convert
,
"
check putAttachment 200 called
"
);
return
"
OK
"
;
};
Storage200
.
prototype
.
buildQuery
=
function
(
options
)
{
equal
(
options
.
query
,
'
portal_type: "Conversion Info"
'
,
"
check buildQuery 200 called
"
);
deepEqual
(
options
.
select_list
,
[
'
convert_dict
'
,
'
doc_id
'
,
'
attachment_id
'
],
'
check buildQuery 200 called
'
);
return
[{
id
:
"
bar
"
,
value
:
{
'
convert_dict
'
:
{
'
docx
'
:
false
},
'
doc_id
'
:
'
bar
'
,
'
attachment_id
'
:
'
data
'
},
doc
:
{}
}];
};
this
.
jio
.
repair
()
.
then
(
function
()
{
equal
(
server
.
requests
.
length
,
1
);
equal
(
server
.
requests
[
0
].
method
,
"
POST
"
);
equal
(
server
.
requests
[
0
].
url
,
cloudoo_url
);
equal
(
server
.
requests
[
0
].
requestBody
,
'
<?xml version="1.0" encoding="UTF-8"?><methodCall>
'
+
'
<methodName>convertFile</methodName><params><param><value>
'
+
'
<string>ZG9jdW1lbnRhdWZvcm1hdGRvY3k=</string></value></param>
'
+
'
<param><value><string>docy</string></value></param>
'
+
'
<param><value><string>docx
'
+
'
</string></value></param></params></methodCall>
'
);
})
.
fail
(
function
(
error
)
{
ok
(
false
,
error
);
})
.
always
(
function
()
{
start
();
});
});
}(
jIO
,
Blob
,
sinon
));
}(
jIO
,
Blob
,
sinon
));
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment