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
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
...
@@ -22,13 +22,20 @@
...
@@ -22,13 +22,20 @@
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
// Tools
// Tools
var
tool
=
{
"
deepClone
"
:
jIO
.
util
.
deepClone
,
"
uniqueJSONStringify
"
:
jIO
.
util
.
uniqueJSONStringify
,
"
readBlobAsBinaryString
"
:
jIO
.
util
.
readBlobAsBinaryString
};
function
generateRevisionHash
(
doc
,
revisions
,
deleted_flag
)
{
function
generateRevisionHash
(
doc
,
revisions
,
deleted_flag
)
{
var
string
;
var
string
;
doc
=
jIO
.
uti
l
.
deepClone
(
doc
);
doc
=
too
l
.
deepClone
(
doc
);
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
(
revisions
)
+
string
=
tool
.
uniqueJSONStringify
(
doc
)
+
tool
.
uniqueJSONStringify
(
revisions
)
+
JSON
.
stringify
(
deleted_flag
?
true
:
false
);
JSON
.
stringify
(
deleted_flag
?
true
:
false
);
return
sha256
.
hex_sha256
(
string
);
return
sha256
.
hex_sha256
(
string
);
}
}
...
@@ -71,7 +78,6 @@
...
@@ -71,7 +78,6 @@
"
type
"
:
"
local
"
,
"
type
"
:
"
local
"
,
"
username
"
:
"
revision post
"
,
"
username
"
:
"
revision post
"
,
"
mode
"
:
"
memory
"
"
mode
"
:
"
memory
"
//"mode": "localStorage"
};
};
jio
=
jIO
.
createJIO
({
jio
=
jIO
.
createJIO
({
...
@@ -144,8 +150,7 @@
...
@@ -144,8 +150,7 @@
"
id
"
:
"
post1
"
,
"
id
"
:
"
post1
"
,
"
method
"
:
"
post
"
,
"
method
"
:
"
post
"
,
"
result
"
:
"
success
"
,
"
result
"
:
"
success
"
,
"
rev
"
:
"
1-eedaf5235af91978a06d0b0e68b1c16adbc539
"
+
"
rev
"
:
shared
.
rev
,
"
5bb9bd4a0cfd632fe03f9d8ef3
"
,
"
status
"
:
201
,
"
status
"
:
201
,
"
statusText
"
:
"
Created
"
"
statusText
"
:
"
Created
"
},
"
Post
"
);
},
"
Post
"
);
...
@@ -266,7 +271,7 @@
...
@@ -266,7 +271,7 @@
"
_id
"
:
"
post1.
"
+
shared
.
rev
,
"
_id
"
:
"
post1.
"
+
shared
.
rev
,
"
_attachment
"
:
"
attachment_test
"
,
"
_attachment
"
:
"
attachment_test
"
,
"
_data
"
:
"
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
"
,
"
_data
"
:
"
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
"
,
"
_
mime
type
"
:
"
oh/yeah
"
"
_
content_
type
"
:
"
oh/yeah
"
});
});
}).
then
(
function
()
{
}).
then
(
function
()
{
...
@@ -299,7 +304,7 @@
...
@@ -299,7 +304,7 @@
}).
then
(
function
(
answer
)
{
}).
then
(
function
(
answer
)
{
return
jIO
.
uti
l
.
readBlobAsBinaryString
(
answer
.
data
);
return
too
l
.
readBlobAsBinaryString
(
answer
.
data
);
}).
then
(
function
(
event
)
{
}).
then
(
function
(
event
)
{
...
@@ -402,7 +407,6 @@
...
@@ -402,7 +407,6 @@
"
type
"
:
"
local
"
,
"
type
"
:
"
local
"
,
"
username
"
:
"
revision put
"
,
"
username
"
:
"
revision put
"
,
"
mode
"
:
"
memory
"
"
mode
"
:
"
memory
"
//"mode": "localStorage"
};
};
jio
=
jIO
.
createJIO
({
jio
=
jIO
.
createJIO
({
...
@@ -634,12 +638,12 @@
...
@@ -634,12 +638,12 @@
"
_id
"
:
"
put1.3-rh3
"
,
"
_id
"
:
"
put1.3-rh3
"
,
"
_attachment
"
:
"
att1
"
,
"
_attachment
"
:
"
att1
"
,
"
_data
"
:
"
a
"
,
"
_data
"
:
"
a
"
,
"
_
mime
type
"
:
"
text/plain
"
"
_
content_
type
"
:
"
text/plain
"
}),
jio_local
.
putAttachment
({
}),
jio_local
.
putAttachment
({
"
_id
"
:
"
put1.3-rh3
"
,
"
_id
"
:
"
put1.3-rh3
"
,
"
_attachment
"
:
"
att2
"
,
"
_attachment
"
:
"
att2
"
,
"
_data
"
:
"
bc
"
,
"
_data
"
:
"
bc
"
,
"
_
mime
type
"
:
"
dont/care
"
"
_
content_
type
"
:
"
dont/care
"
})]);
})]);
}).
then
(
function
()
{
}).
then
(
function
()
{
...
@@ -687,8 +691,8 @@
...
@@ -687,8 +691,8 @@
deepEqual
(
answers
[
1
].
data
.
type
,
"
dont/care
"
,
"
Check attachment 2 type
"
);
deepEqual
(
answers
[
1
].
data
.
type
,
"
dont/care
"
,
"
Check attachment 2 type
"
);
return
RSVP
.
all
([
return
RSVP
.
all
([
jIO
.
uti
l
.
readBlobAsBinaryString
(
answers
[
0
].
data
),
too
l
.
readBlobAsBinaryString
(
answers
[
0
].
data
),
jIO
.
uti
l
.
readBlobAsBinaryString
(
answers
[
1
].
data
)
too
l
.
readBlobAsBinaryString
(
answers
[
1
].
data
)
]);
]);
}).
then
(
function
(
answers
)
{
}).
then
(
function
(
answers
)
{
...
@@ -714,174 +718,236 @@
...
@@ -714,174 +718,236 @@
});
});
//
test("Put Attachment", function () {
test
(
"
Put Attachment
"
,
function
()
{
// var o = generateTools()
;
var
shared
=
{},
jio
,
jio_local
;
// o.jio = jIO.newJio({
shared
.
workspace
=
{};
// "type": "revision",
shared
.
local_storage_description
=
{
// "sub_storage": {
"
type
"
:
"
local
"
,
// "type": "local",
"
username
"
:
"
revision putAttachment
"
,
// "username": "urevputattmt",
"
mode
"
:
"
memory
"
// "application_name": "arevputattmt"
};
// }
// });
// // putAttachment without doc id
jio
=
jIO
.
createJIO
({
// // error 20 -> document id required
"
type
"
:
"
revision
"
,
// o.spy(o, "status", 20, "PutAttachment without doc id" +
"
sub_storage
"
:
shared
.
local_storage_description
// " -> 20 document id required");
},
{
"
workspace
"
:
shared
.
workspace
});
// o.jio.putAttachment({}, o.f);
// o.tick(o);
// // putAttachment without attachment id
jio_local
=
jIO
.
createJIO
(
shared
.
local_storage_description
,
{
// // erorr 22 -> attachment id required
"
workspace
"
:
shared
.
workspace
// o.spy(o, "status", 22, "PutAttachment without attachment id" +
});
// " -> 22 attachment id required");
// o.jio.putAttachment({"_id": "putattmt1"}, o.f);
// o.tick(o);
// // putAttachment without document
stop
();
// o.revisions = {"start": 0, "ids": []};
// o.rev_hash = generateRevisionHash({"_id": "doc1", "_attachment": "attmt1"},
// o.revisions);
// o.rev = "1-" + o.rev_hash;
// o.spy(o, "value",
// {"ok": true, "id": "doc1", "attachment": "attmt1", "rev": o.rev},
// "PutAttachment without document, without data");
// o.jio.putAttachment({"_id": "doc1", "_attachment": "attmt1"}, o.f);
// o.tick(o);
// // check document
// putAttachment without document
// deepEqual(
shared
.
revisions
=
{
"
start
"
:
0
,
"
ids
"
:
[]};
// util.jsonlocalstorage.getItem(
shared
.
rev_hash
=
generateRevisionHash
({
// "jio/localstorage/urevputattmt/arevputattmt/doc1." + o.rev
"
_id
"
:
"
doc1
"
,
// ),
"
_attachment
"
:
"
attmt1
"
,
// {
"
_data
"
:
""
,
// "_id": "doc1." + o.rev,
"
_content_type
"
:
""
// "_attachments": {
},
shared
.
revisions
);
// "attmt1": {
shared
.
rev
=
"
1-
"
+
shared
.
rev_hash
;
// "length": 0,
jio
.
putAttachment
({
// // md5("")
"
_id
"
:
"
doc1
"
,
// "digest": "md5-d41d8cd98f00b204e9800998ecf8427e"
"
_attachment
"
:
"
attmt1
"
,
// }
"
_data
"
:
""
// }
}).
then
(
function
(
answer
)
{
// },
// "Check document"
// );
// // check attachment
deepEqual
(
answer
,
{
// deepEqual(util.jsonlocalstorage.getItem(
"
attachment
"
:
"
attmt1
"
,
// "jio/localstorage/urevputattmt/arevputattmt/doc1." + o.rev
"
id
"
:
"
doc1
"
,
// + "/attmt1"
"
method
"
:
"
putAttachment
"
,
// ), "", "Check attachment");
"
result
"
:
"
success
"
,
// // adding a metadata to the document
"
rev
"
:
shared
.
rev
,
// o.doc = util.jsonlocalstorage.getItem(
"
status
"
:
204
,
// "jio/localstorage/urevputattmt/arevputattmt/doc1." + o.rev
"
statusText
"
:
"
No Content
"
// XXX should be 201 Created
// );
},
"
PutAttachment without document
"
);
// o.doc.title = "My Title";
// util.jsonlocalstorage.setItem(
// "jio/localstorage/urevputattmt/arevputattmt/doc1." + o.rev,
// o.doc
// );
// // update attachment
return
jio_local
.
get
({
"
_id
"
:
"
doc1.
"
+
shared
.
rev
});
// o.prev_rev = o.rev;
// o.revisions = {"start": 1, "ids": [o.rev_hash]};
// o.rev_hash = generateRevisionHash({
// "_id": "doc1",
// "_data": "abc",
// "_attachment": "attmt1",
// }, o.revisions);
// o.rev = "2-" + o.rev_hash;
// o.spy(o, "value",
// {"ok": true, "id": "doc1", "attachment": "attmt1", "rev": o.rev},
// "Update Attachment, with data");
// o.jio.putAttachment({
// "_id": "doc1",
// "_data": "abc",
// "_attachment": "attmt1",
// "_rev": o.prev_rev
// }, o.f);
// o.tick(o);
// // check document
}).
then
(
function
(
answer
)
{
// deepEqual(
// util.jsonlocalstorage.getItem(
// "jio/localstorage/urevputattmt/arevputattmt/doc1." + o.rev
// ),
// {
// "_id": "doc1." + o.rev,
// "title": "My Title",
// "_attachments": {
// "attmt1": {
// "length": 3,
// // md5("abc")
// "digest": "md5-900150983cd24fb0d6963f7d28e17f72"
// }
// }
// },
// "Check document"
// );
// // check attachment
// check document
// deepEqual(util.jsonlocalstorage.getItem(
deepEqual
(
// "jio/localstorage/urevputattmt/arevputattmt/doc1." + o.rev +
answer
.
data
,
// "/attmt1"
{
// ), "abc", "Check attachment");
"
_id
"
:
"
doc1.
"
+
shared
.
rev
,
"
_attachments
"
:
{
"
attmt1
"
:
{
"
content_type
"
:
""
,
"
length
"
:
0
,
"
digest
"
:
"
sha256-e3b0c44298fc1c149afbf4c8996fb9242
"
+
"
7ae41e4649b934ca495991b7852b855
"
}
}
},
"
Check document
"
);
// // putAttachment new attachment
// check attachment
// o.prev_rev = o.rev;
return
jio_local
.
getAttachment
({
// o.revisions = {"start": 2, "ids": [o.rev_hash, o.revisions.ids[0]]};
"
_id
"
:
"
doc1.
"
+
shared
.
rev
,
// o.rev_hash = generateRevisionHash({
"
_attachment
"
:
"
attmt1
"
// "_id": "doc1",
});
// "_data": "def",
// "_attachment": "attmt2",
// }, o.revisions);
// o.rev = "3-" + o.rev_hash;
// o.spy(o, "value",
// {"ok": true, "id": "doc1", "attachment": "attmt2", "rev": o.rev},
// "PutAttachment without document, without data");
// o.jio.putAttachment({
// "_id": "doc1",
// "_data": "def",
// "_attachment": "attmt2",
// "_rev": o.prev_rev
// }, o.f);
// o.tick(o);
// // check document
}).
then
(
function
(
answer
)
{
// deepEqual(
// util.jsonlocalstorage.getItem(
// "jio/localstorage/urevputattmt/arevputattmt/doc1." + o.rev
// ),
// {
// "_id": "doc1." + o.rev,
// "title": "My Title",
// "_attachments": {
// "attmt1": {
// "length": 3,
// "digest": "md5-900150983cd24fb0d6963f7d28e17f72"
// },
// "attmt2": {
// "length": 3,
// // md5("def")
// "digest": "md5-4ed9407630eb1000c0f6b63842defa7d"
// }
// }
// },
// "Check document"
// );
// // check attachment
return
tool
.
readBlobAsBinaryString
(
answer
.
data
);
// deepEqual(util.jsonlocalstorage.getItem(
// "jio/localstorage/urevputattmt/arevputattmt/doc1." + o.rev +
// "/attmt2"
// ), "def", "Check attachment");
// util.closeAndcleanUpJio(o.jio);
}).
then
(
function
(
event
)
{
// });
deepEqual
(
event
.
target
.
result
,
""
,
"
Check attachment
"
);
// adding a metadata to the document
return
jio_local
.
get
({
"
_id
"
:
"
doc1.
"
+
shared
.
rev
});
}).
then
(
function
(
answer
)
{
answer
.
data
.
_id
=
"
doc1.
"
+
shared
.
rev
;
answer
.
data
.
title
=
"
My Title
"
;
return
jio_local
.
put
(
answer
.
data
);
}).
then
(
function
()
{
// update attachment
shared
.
prev_rev
=
shared
.
rev
;
shared
.
revisions
=
{
"
start
"
:
1
,
"
ids
"
:
[
shared
.
rev_hash
]};
shared
.
rev_hash
=
generateRevisionHash
({
"
_id
"
:
"
doc1
"
,
"
_data
"
:
"
abc
"
,
"
_content_type
"
:
""
,
"
_attachment
"
:
"
attmt1
"
},
shared
.
revisions
);
shared
.
rev
=
"
2-
"
+
shared
.
rev_hash
;
return
jio
.
putAttachment
({
"
_id
"
:
"
doc1
"
,
"
_data
"
:
"
abc
"
,
"
_attachment
"
:
"
attmt1
"
,
"
_rev
"
:
shared
.
prev_rev
});
}).
then
(
function
(
answer
)
{
deepEqual
(
answer
,
{
"
attachment
"
:
"
attmt1
"
,
"
id
"
:
"
doc1
"
,
"
method
"
:
"
putAttachment
"
,
"
result
"
:
"
success
"
,
"
rev
"
:
shared
.
rev
,
"
status
"
:
204
,
"
statusText
"
:
"
No Content
"
},
"
Update attachment
"
);
// check document
return
jio_local
.
get
({
"
_id
"
:
"
doc1.
"
+
shared
.
rev
});
}).
then
(
function
(
answer
)
{
deepEqual
(
answer
.
data
,
{
"
_id
"
:
"
doc1.
"
+
shared
.
rev
,
"
title
"
:
"
My Title
"
,
"
_attachments
"
:
{
"
attmt1
"
:
{
"
content_type
"
:
""
,
"
length
"
:
3
,
"
digest
"
:
"
sha256-ba7816bf8f01cfea414140de5dae2223b00361a3
"
+
"
96177a9cb410ff61f20015ad
"
}
}
},
"
Check document
"
);
// check attachment
return
jio_local
.
getAttachment
({
"
_id
"
:
"
doc1.
"
+
shared
.
rev
,
"
_attachment
"
:
"
attmt1
"
});
}).
then
(
function
(
answer
)
{
return
tool
.
readBlobAsBinaryString
(
answer
.
data
);
}).
then
(
function
(
event
)
{
deepEqual
(
event
.
target
.
result
,
"
abc
"
,
"
Check attachment
"
);
// putAttachment new attachment
shared
.
prev_rev
=
shared
.
rev
;
shared
.
revisions
=
{
"
start
"
:
2
,
"
ids
"
:
[
shared
.
rev_hash
,
shared
.
revisions
.
ids
[
0
]]
};
shared
.
rev_hash
=
generateRevisionHash
({
"
_id
"
:
"
doc1
"
,
"
_data
"
:
"
def
"
,
"
_attachment
"
:
"
attmt2
"
,
"
_content_type
"
:
""
},
shared
.
revisions
);
shared
.
rev
=
"
3-
"
+
shared
.
rev_hash
;
return
jio
.
putAttachment
({
"
_id
"
:
"
doc1
"
,
"
_data
"
:
"
def
"
,
"
_attachment
"
:
"
attmt2
"
,
"
_rev
"
:
shared
.
prev_rev
});
}).
then
(
function
(
answer
)
{
deepEqual
(
answer
,
{
"
attachment
"
:
"
attmt2
"
,
"
id
"
:
"
doc1
"
,
"
method
"
:
"
putAttachment
"
,
"
result
"
:
"
success
"
,
"
rev
"
:
shared
.
rev
,
"
status
"
:
204
,
"
statusText
"
:
"
No Content
"
// XXX should be 201 Created
},
"
PutAttachment without document
"
);
return
jio_local
.
get
({
"
_id
"
:
"
doc1.
"
+
shared
.
rev
});
}).
then
(
function
(
answer
)
{
deepEqual
(
answer
.
data
,
{
"
_id
"
:
"
doc1.
"
+
shared
.
rev
,
"
title
"
:
"
My Title
"
,
"
_attachments
"
:
{
"
attmt1
"
:
{
"
content_type
"
:
""
,
"
length
"
:
3
,
"
digest
"
:
"
sha256-ba7816bf8f01cfea414140de5dae2223b00361a3
"
+
"
96177a9cb410ff61f20015ad
"
},
"
attmt2
"
:
{
"
content_type
"
:
""
,
"
length
"
:
3
,
"
digest
"
:
"
sha256-cb8379ac2098aa165029e3938a51da0bcecfc008
"
+
"
fd6795f401178647f96c5b34
"
}
}
},
"
Check document
"
);
// check attachment
return
jio_local
.
getAttachment
({
"
_id
"
:
"
doc1.
"
+
shared
.
rev
,
"
_attachment
"
:
"
attmt2
"
});
}).
then
(
function
(
answer
)
{
return
tool
.
readBlobAsBinaryString
(
answer
.
data
);
}).
then
(
function
(
event
)
{
deepEqual
(
event
.
target
.
result
,
"
def
"
,
"
Check attachment
"
);
}).
fail
(
unexpectedError
).
always
(
start
);
});
// test("Get", function () {
// test("Get", function () {
...
...
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