Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
jio-main
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
Hardik Juneja
jio-main
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
Show 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,6 +828,10 @@
...
@@ -821,6 +828,10 @@
that
.
putAttachment
=
function
(
command
,
param
,
option
)
{
that
.
putAttachment
=
function
(
command
,
param
,
option
)
{
tool
.
readBlobAsBinaryString
(
param
.
_blob
).
then
(
function
(
event
)
{
param
.
_content_type
=
param
.
_blob
.
type
;
param
.
_data
=
event
.
target
.
result
;
delete
param
.
_blob
;
priv
.
revisionGenericRequest
(
priv
.
revisionGenericRequest
(
command
,
command
,
param
,
param
,
...
@@ -830,18 +841,21 @@
...
@@ -830,18 +841,21 @@
"
attachment_id
"
:
param
.
_attachment
,
"
attachment_id
"
:
param
.
_attachment
,
"
add_to_attachment_list
"
:
{
"
add_to_attachment_list
"
:
{
"
_attachment
"
:
param
.
_attachment
,
"
_attachment
"
:
param
.
_attachment
,
"
_mimetype
"
:
param
.
_blob
.
type
,
"
_content_type
"
:
param
.
_content_
type
,
"
_data
"
:
param
.
_blob
"
_data
"
:
param
.
_data
},
},
"
putAttachment
"
:
true
"
putAttachment
"
:
true
},
},
function
(
err
)
{
function
(
err
,
response
)
{
if
(
err
)
{
if
(
err
)
{
return
command
.
error
(
err
);
return
command
.
error
(
err
);
}
}
command
.
success
(
);
command
.
success
({
"
rev
"
:
response
.
rev
}
);
}
}
);
);
},
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