Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
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
Boris Kocherov
jio
Commits
7324f225
Commit
7324f225
authored
Oct 27, 2016
by
Vincent Bechu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mappingstorage: modify attachment uritemplate and test
parent
09cc6aec
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
140 additions
and
8 deletions
+140
-8
src/jio.storage/mappingstorage.js
src/jio.storage/mappingstorage.js
+7
-1
test/jio.storage/mappingstorage.tests.js
test/jio.storage/mappingstorage.tests.js
+133
-7
No files found.
src/jio.storage/mappingstorage.js
View file @
7324f225
...
...
@@ -52,7 +52,7 @@
.
push
(
function
()
{
if
(
mapping_dict
!==
undefined
&&
mapping_dict
[
attachment_id
]
!==
undefined
&&
mapping_dict
[
attachment_id
].
uri_template
!==
undefined
)
{
&&
mapping_dict
[
attachment_id
]
[
method
]
.
uri_template
!==
undefined
)
{
return
UriTemplate
.
parse
(
mapping_dict
[
attachment_id
][
method
].
uri_template
).
expand
({
id
:
sub_id
});
...
...
@@ -253,6 +253,9 @@
argument_list
[
1
]
=
sub_attachment_id
;
return
context
.
_sub_storage
.
putAttachment
.
apply
(
context
.
_sub_storage
,
argument_list
);
})
.
push
(
function
()
{
return
attachment_id
;
});
};
...
...
@@ -281,6 +284,9 @@
argument_list
[
1
]
=
sub_attachment_id
;
return
context
.
_sub_storage
.
removeAttachment
.
apply
(
context
.
_sub_storage
,
argument_list
);
})
.
push
(
function
()
{
return
attachment_id
;
});
};
...
...
test/jio.storage/mappingstorage.tests.js
View file @
7324f225
...
...
@@ -492,7 +492,7 @@
};
jio
.
putAttachment
(
"
42
"
,
"
2713
"
,
blob
)
.
then
(
function
(
result
)
{
equal
(
result
,
"
42
"
);
equal
(
result
,
"
2713
"
);
})
.
fail
(
function
(
error
)
{
ok
(
false
,
error
);
...
...
@@ -523,7 +523,50 @@
};
jio
.
putAttachment
(
"
42
"
,
"
2713
"
,
blob
)
.
then
(
function
(
result
)
{
equal
(
result
,
"
42
"
);
equal
(
result
,
"
2713
"
);
})
.
fail
(
function
(
error
)
{
ok
(
false
,
error
);
})
.
always
(
function
()
{
start
();
});
});
test
(
"
putAttachment with UriTemplate and id mapped
"
,
function
()
{
stop
();
expect
(
5
);
var
jio
=
jIO
.
createJIO
({
type
:
"
mapping
"
,
sub_storage
:
{
type
:
"
mappingstorage2713
"
},
mapping_dict
:
{
"
id
"
:
{
"
equal
"
:
"
otherId
"
}},
mapping_dict_attachment
:
{
"
2713
"
:
{
"
put
"
:
{
"
uri_template
"
:
"
www.2713.foo/{id}
"
}}}
}),
blob
=
new
Blob
([
""
]);
Storage2713
.
prototype
.
putAttachment
=
function
(
id
,
attachment_id
,
attachment
)
{
equal
(
id
,
"
13
"
,
"
putAttachment 2713 called
"
);
equal
(
attachment_id
,
"
www.2713.foo/13
"
,
"
putAttachment 2713 called
"
);
deepEqual
(
attachment
,
blob
,
"
putAttachment 2713 called
"
);
return
id
;
};
Storage2713
.
prototype
.
hasCapacity
=
function
()
{
return
true
;
};
Storage2713
.
prototype
.
buildQuery
=
function
(
option
)
{
equal
(
option
.
query
,
'
otherId: "42"
'
);
return
[{
"
id
"
:
"
13
"
}];
};
jio
.
putAttachment
(
"
42
"
,
"
2713
"
,
blob
)
.
then
(
function
(
result
)
{
equal
(
result
,
"
2713
"
);
})
.
fail
(
function
(
error
)
{
ok
(
false
,
error
);
...
...
@@ -595,6 +638,48 @@
});
});
test
(
"
getAttachment with UriTemplate and id mapped
"
,
function
()
{
stop
();
expect
(
4
);
var
jio
=
jIO
.
createJIO
({
type
:
"
mapping
"
,
sub_storage
:
{
type
:
"
mappingstorage2713
"
},
mapping_dict
:
{
"
id
"
:
{
"
equal
"
:
"
otherId
"
}},
mapping_dict_attachment
:
{
"
2713
"
:
{
"
get
"
:
{
"
uri_template
"
:
"
www.2713.foo/{id}
"
}}}
}),
blob
=
new
Blob
([
""
]);
Storage2713
.
prototype
.
getAttachment
=
function
(
id
,
attachment_id
)
{
equal
(
id
,
"
13
"
,
"
getAttachment 2713 called
"
);
equal
(
attachment_id
,
"
www.2713.foo/13
"
,
"
getAttachment 2713 called
"
);
return
blob
;
};
Storage2713
.
prototype
.
hasCapacity
=
function
()
{
return
true
;
};
Storage2713
.
prototype
.
buildQuery
=
function
(
option
)
{
equal
(
option
.
query
,
'
otherId: "42"
'
);
return
[{
"
id
"
:
"
13
"
}];
};
jio
.
getAttachment
(
"
42
"
,
"
2713
"
)
.
then
(
function
(
result
)
{
deepEqual
(
result
,
blob
);
})
.
fail
(
function
(
error
)
{
ok
(
false
,
error
);
})
.
always
(
function
()
{
start
();
});
});
/////////////////////////////////////////////////////////////////
// mappingStorage.removeAttachment
/////////////////////////////////////////////////////////////////
...
...
@@ -610,13 +695,13 @@
}
});
Storage2713
.
prototype
.
removeAttachment
=
function
(
doc_id
,
attachment
)
{
equal
(
doc_id
,
"
42
"
,
"
put
Attachment 2713 called
"
);
equal
(
doc_id
,
"
42
"
,
"
remove
Attachment 2713 called
"
);
equal
(
attachment
,
"
2713
"
,
"
getAttachment 2713 called
"
);
return
doc_id
;
};
jio
.
removeAttachment
(
"
42
"
,
"
2713
"
)
.
then
(
function
(
result
)
{
deepEqual
(
result
,
"
42
"
);
deepEqual
(
result
,
"
2713
"
);
})
.
fail
(
function
(
error
)
{
ok
(
false
,
error
);
...
...
@@ -638,13 +723,54 @@
{
"
remove
"
:
{
"
uri_template
"
:
"
www.2713/{id}.bar
"
}}}
});
Storage2713
.
prototype
.
removeAttachment
=
function
(
doc_id
,
attachment
)
{
equal
(
doc_id
,
"
42
"
,
"
put
Attachment 2713 called
"
);
equal
(
attachment
,
"
www.2713/42.bar
"
,
"
get
Attachment 2713 called
"
);
equal
(
doc_id
,
"
42
"
,
"
remove
Attachment 2713 called
"
);
equal
(
attachment
,
"
www.2713/42.bar
"
,
"
remove
Attachment 2713 called
"
);
return
doc_id
;
};
jio
.
removeAttachment
(
"
42
"
,
"
2713
"
)
.
then
(
function
(
result
)
{
deepEqual
(
result
,
"
42
"
);
deepEqual
(
result
,
"
2713
"
);
})
.
fail
(
function
(
error
)
{
ok
(
false
,
error
);
})
.
always
(
function
()
{
start
();
});
});
test
(
"
removeAttachment with UriTemplate and id mapped
"
,
function
()
{
stop
();
expect
(
4
);
var
jio
=
jIO
.
createJIO
({
type
:
"
mapping
"
,
sub_storage
:
{
type
:
"
mappingstorage2713
"
},
mapping_dict
:
{
"
id
"
:
{
"
equal
"
:
"
otherId
"
}},
mapping_dict_attachment
:
{
"
2713
"
:
{
"
remove
"
:
{
"
uri_template
"
:
"
www.2713.foo/{id}
"
}}}
});
Storage2713
.
prototype
.
removeAttachment
=
function
(
id
,
attachment_id
)
{
equal
(
id
,
"
13
"
,
"
removeAttachment 2713 called
"
);
equal
(
attachment_id
,
"
www.2713.foo/13
"
,
"
removeAttachment 2713 called
"
);
return
id
;
};
Storage2713
.
prototype
.
hasCapacity
=
function
()
{
return
true
;
};
Storage2713
.
prototype
.
buildQuery
=
function
(
option
)
{
equal
(
option
.
query
,
'
otherId: "42"
'
);
return
[{
"
id
"
:
"
13
"
}];
};
jio
.
removeAttachment
(
"
42
"
,
"
2713
"
)
.
then
(
function
(
result
)
{
equal
(
result
,
"
2713
"
);
})
.
fail
(
function
(
error
)
{
ok
(
false
,
error
);
...
...
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