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
Aurélien Vermylen
jio
Commits
3ad7eaba
Commit
3ad7eaba
authored
Dec 05, 2013
by
Tristan Cavelier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
revisionstorage putAttachment unit tests done
parent
c1a8aff1
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
271 additions
and
191 deletions
+271
-191
src/jio.storage/revisionstorage.js
src/jio.storage/revisionstorage.js
+36
-22
test/jio.storage/revisionstorage.tests.js
test/jio.storage/revisionstorage.tests.js
+235
-169
No files found.
src/jio.storage/revisionstorage.js
View file @
3ad7eaba
...
@@ -20,6 +20,11 @@
...
@@ -20,6 +20,11 @@
}([
'
jio
'
,
'
sha256
'
],
function
(
jIO
,
sha256
)
{
}([
'
jio
'
,
'
sha256
'
],
function
(
jIO
,
sha256
)
{
"
use strict
"
;
"
use strict
"
;
var
tool
=
{
"
readBlobAsBinaryString
"
:
jIO
.
util
.
readBlobAsBinaryString
,
"
uniqueJSONStringify
"
:
jIO
.
util
.
uniqueJSONStringify
};
jIO
.
addStorage
(
"
revision
"
,
function
(
spec
)
{
jIO
.
addStorage
(
"
revision
"
,
function
(
spec
)
{
var
that
=
this
,
priv
=
{};
var
that
=
this
,
priv
=
{};
...
@@ -225,7 +230,8 @@
...
@@ -225,7 +230,8 @@
delete
doc
.
_rev
;
delete
doc
.
_rev
;
delete
doc
.
_revs
;
delete
doc
.
_revs
;
delete
doc
.
_revs_info
;
delete
doc
.
_revs_info
;
string
=
JSON
.
stringify
(
doc
)
+
JSON
.
stringify
(
revision_history
)
+
string
=
tool
.
uniqueJSONStringify
(
doc
)
+
tool
.
uniqueJSONStringify
(
revision_history
)
+
JSON
.
stringify
(
deleted_flag
?
true
:
false
);
JSON
.
stringify
(
deleted_flag
?
true
:
false
);
revision_history
.
start
+=
1
;
revision_history
.
start
+=
1
;
revision_history
.
ids
.
unshift
(
priv
.
hashCode
(
string
));
revision_history
.
ids
.
unshift
(
priv
.
hashCode
(
string
));
...
@@ -389,6 +395,7 @@
...
@@ -389,6 +395,7 @@
delete
doc
.
_attachment
;
delete
doc
.
_attachment
;
delete
doc
.
_data
;
delete
doc
.
_data
;
delete
doc
.
_mimetype
;
delete
doc
.
_mimetype
;
delete
doc
.
_content_type
;
delete
doc
.
_rev
;
delete
doc
.
_rev
;
delete
doc
.
_revs
;
delete
doc
.
_revs
;
delete
doc
.
_revs_info
;
delete
doc
.
_revs_info
;
...
@@ -428,7 +435,7 @@
...
@@ -428,7 +435,7 @@
result_list
.
push
({
result_list
.
push
({
"
_attachment
"
:
attachment_id
,
"
_attachment
"
:
attachment_id
,
"
_data
"
:
response
.
data
,
"
_data
"
:
response
.
data
,
"
_
mime
type
"
:
attachment_meta
.
content_type
"
_
content_
type
"
:
attachment_meta
.
content_type
});
});
if
(
count
===
0
)
{
if
(
count
===
0
)
{
state
=
"
finished
"
;
state
=
"
finished
"
;
...
@@ -625,7 +632,7 @@
...
@@ -625,7 +632,7 @@
"
missing
"
"
missing
"
),
undefined
);
),
undefined
);
}
}
res_doc
=
{
"
data
"
:{}};
res_doc
=
{
"
data
"
:
{}};
}
else
{
}
else
{
err
.
message
=
"
Cannot get document
"
;
err
.
message
=
"
Cannot get document
"
;
return
onEnd
(
err
,
undefined
);
return
onEnd
(
err
,
undefined
);
...
@@ -821,27 +828,34 @@
...
@@ -821,27 +828,34 @@
that
.
putAttachment
=
function
(
command
,
param
,
option
)
{
that
.
putAttachment
=
function
(
command
,
param
,
option
)
{
priv
.
revisionGenericRequest
(
tool
.
readBlobAsBinaryString
(
param
.
_blob
).
then
(
function
(
event
)
{
command
,
param
.
_content_type
=
param
.
_blob
.
type
;
param
,
param
.
_data
=
event
.
target
.
result
;
option
,
delete
param
.
_blob
;
{
priv
.
revisionGenericRequest
(
"
doc_id
"
:
param
.
_id
,
command
,
"
attachment_id
"
:
param
.
_attachment
,
param
,
"
add_to_attachment_list
"
:
{
option
,
"
_attachment
"
:
param
.
_attachment
,
{
"
_mimetype
"
:
param
.
_blob
.
type
,
"
doc_id
"
:
param
.
_id
,
"
_data
"
:
param
.
_blob
"
attachment_id
"
:
param
.
_attachment
,
"
add_to_attachment_list
"
:
{
"
_attachment
"
:
param
.
_attachment
,
"
_content_type
"
:
param
.
_content_type
,
"
_data
"
:
param
.
_data
},
"
putAttachment
"
:
true
},
},
"
putAttachment
"
:
true
function
(
err
,
response
)
{
},
if
(
err
)
{
function
(
err
)
{
return
command
.
error
(
err
);
if
(
err
)
{
}
return
command
.
error
(
err
);
command
.
success
({
"
rev
"
:
response
.
rev
}
);
}
}
command
.
success
();
);
}
},
function
()
{
);
command
.
error
(
"
conflict
"
,
"
broken blob
"
,
"
Cannot read data to put
"
);
});
};
};
that
.
remove
=
function
(
command
,
param
,
option
)
{
that
.
remove
=
function
(
command
,
param
,
option
)
{
...
...
test/jio.storage/revisionstorage.tests.js
View file @
3ad7eaba
This diff is collapsed.
Click to expand it.
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