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
b968fe14
Commit
b968fe14
authored
Nov 24, 2016
by
Vincent Bechu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mappingstorage: add allAtachments and test
parent
9c0c1922
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
95 additions
and
2 deletions
+95
-2
src/jio.storage/mappingstorage.js
src/jio.storage/mappingstorage.js
+32
-2
test/jio.storage/mappingstorage.tests.js
test/jio.storage/mappingstorage.tests.js
+63
-0
No files found.
src/jio.storage/mappingstorage.js
View file @
b968fe14
...
@@ -281,8 +281,38 @@
...
@@ -281,8 +281,38 @@
});
});
};
};
MappingStorage
.
prototype
.
hasCapacity
=
function
()
{
MappingStorage
.
prototype
.
allAttachments
=
function
(
id
)
{
return
this
.
_sub_storage
.
hasCapacity
.
apply
(
this
.
_sub_storage
,
arguments
);
var
context
=
this
,
sub_id
;
return
getSubStorageId
(
context
,
id
)
.
push
(
function
(
sub_id_result
)
{
sub_id
=
sub_id_result
;
return
context
.
_sub_storage
.
allAttachments
(
sub_id
);
})
.
push
(
function
(
result
)
{
var
attachment_id
,
attachments
=
{},
mapping_dict
=
{};
for
(
attachment_id
in
context
.
_attachment_mapping_dict
)
{
if
(
context
.
_attachment_mapping_dict
.
hasOwnProperty
(
attachment_id
))
{
mapping_dict
[
getAttachmentId
(
context
,
sub_id
,
attachment_id
,
"
get
"
)]
=
attachment_id
;
}
}
for
(
attachment_id
in
result
)
{
if
(
result
.
hasOwnProperty
(
attachment_id
))
{
if
(
mapping_dict
.
hasOwnProperty
(
attachment_id
))
{
attachments
[
mapping_dict
[
attachment_id
]]
=
{};
}
else
{
attachments
[
attachment_id
]
=
{};
}
}
}
return
attachments
;
});
};
MappingStorage
.
prototype
.
hasCapacity
=
function
(
name
)
{
return
this
.
_sub_storage
.
hasCapacity
(
name
);
};
};
MappingStorage
.
prototype
.
repair
=
function
()
{
MappingStorage
.
prototype
.
repair
=
function
()
{
...
...
test/jio.storage/mappingstorage.tests.js
View file @
b968fe14
...
@@ -862,6 +862,69 @@
...
@@ -862,6 +862,69 @@
});
});
});
});
/////////////////////////////////////////////////////////////////
// mappingStorage.allAttachments
/////////////////////////////////////////////////////////////////
module
(
"
mappingStorage.allAttachments
"
);
test
(
"
allAttachments use sub_storage one's
"
,
function
()
{
stop
();
expect
(
2
);
var
jio
=
jIO
.
createJIO
({
type
:
"
mapping
"
,
sub_storage
:
{
type
:
"
mappingstorage2713
"
}
});
Storage2713
.
prototype
.
allAttachments
=
function
(
doc_id
)
{
equal
(
doc_id
,
"
42
"
,
"
allAttachments 2713 called
"
);
return
{};
};
jio
.
allAttachments
(
"
42
"
)
.
push
(
function
(
result
)
{
deepEqual
(
result
,
{});
})
.
push
(
undefined
,
function
(
error
)
{
ok
(
false
,
error
);
})
.
always
(
function
()
{
start
();
});
});
test
(
"
allAttachments use UriTemplate
"
,
function
()
{
stop
();
expect
(
2
);
var
jio
=
jIO
.
createJIO
({
type
:
"
mapping
"
,
sub_storage
:
{
type
:
"
mappingstorage2713
"
},
attachment_mapping_dict
:
{
"
2713
"
:
{
"
get
"
:
{
"
uri_template
"
:
"
www.2713.bar
"
}}
}
});
Storage2713
.
prototype
.
allAttachments
=
function
(
doc_id
)
{
equal
(
doc_id
,
"
42
"
,
"
allAttachments 2713 called
"
);
return
{
"
www.2713.bar
"
:
{}};
};
jio
.
allAttachments
(
"
42
"
)
.
push
(
function
(
result
)
{
deepEqual
(
result
,
{
"
2713
"
:
{}});
})
.
push
(
undefined
,
function
(
error
)
{
ok
(
false
,
error
);
})
.
always
(
function
()
{
start
();
});
});
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
// mappingStorage.allDocs
// mappingStorage.allDocs
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
...
...
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