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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Aurel
jio
Commits
e00aa43c
Commit
e00aa43c
authored
Jan 11, 2017
by
Vincent Bechu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mappingstorage: fix post and add tests
parent
da7179f8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
73 additions
and
9 deletions
+73
-9
src/jio.storage/mappingstorage.js
src/jio.storage/mappingstorage.js
+10
-5
test/jio.storage/mappingstorage.tests.js
test/jio.storage/mappingstorage.tests.js
+63
-4
No files found.
src/jio.storage/mappingstorage.js
View file @
e00aa43c
...
@@ -260,11 +260,16 @@
...
@@ -260,11 +260,16 @@
};
};
MappingStorage
.
prototype
.
post
=
function
(
doc
)
{
MappingStorage
.
prototype
.
post
=
function
(
doc
)
{
if
(
!
this
.
_id_is_mapped
)
{
var
sub_doc
=
mapToSubstorageDocument
(
return
this
.
_sub_storage
.
post
(
mapToSubstorageDocument
(
this
,
this
,
doc
doc
),
));
id
=
doc
[
this
.
_property_for_sub_id
];
if
(
this
.
_property_for_sub_id
&&
id
!==
undefined
)
{
return
this
.
_sub_storage
.
put
(
id
,
sub_doc
);
}
if
(
!
this
.
_id_mapped
||
doc
[
this
.
_id_mapped
]
!==
undefined
)
{
return
this
.
_sub_storage
.
post
(
sub_doc
);
}
}
throw
new
jIO
.
util
.
jIOError
(
throw
new
jIO
.
util
.
jIOError
(
"
post is not supported with id mapped
"
,
"
post is not supported with id mapped
"
,
...
...
test/jio.storage/mappingstorage.tests.js
View file @
e00aa43c
...
@@ -421,7 +421,7 @@
...
@@ -421,7 +421,7 @@
};
};
Storage2713
.
prototype
.
buildQuery
=
function
(
option
)
{
Storage2713
.
prototype
.
buildQuery
=
function
(
option
)
{
equal
(
option
.
query
,
'
otherId: "42"
'
,
"
allDocs 2713 called
"
);
equal
(
option
.
query
,
'
otherId:
"42"
'
,
"
allDocs 2713 called
"
);
return
[];
return
[];
};
};
...
@@ -580,7 +580,7 @@
...
@@ -580,7 +580,7 @@
});
});
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
// mappingStorage.
remove
// mappingStorage.
post
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
module
(
"
mappingStorage.post
"
);
module
(
"
mappingStorage.post
"
);
...
@@ -615,7 +615,7 @@
...
@@ -615,7 +615,7 @@
});
});
});
});
test
(
"
post with id mapped
"
,
function
()
{
test
(
"
post with id mapped
, no id in doc
"
,
function
()
{
stop
();
stop
();
expect
(
2
);
expect
(
2
);
...
@@ -640,6 +640,65 @@
...
@@ -640,6 +640,65 @@
start
();
start
();
});
});
});
});
test
(
"
post with id mapped and in doc
"
,
function
()
{
stop
();
expect
(
2
);
var
jio
=
jIO
.
createJIO
({
type
:
"
mapping
"
,
map_id
:
[
"
equalSubProperty
"
,
"
otherId
"
],
sub_storage
:
{
type
:
"
mappingstorage2713
"
}
});
Storage2713
.
prototype
.
post
=
function
(
doc
)
{
deepEqual
(
doc
,
{
"
title
"
:
"
foo
"
,
"
otherId
"
:
"
bar
"
},
"
post 2713 called
"
);
return
"
42
"
;
};
jio
.
post
({
"
title
"
:
"
foo
"
,
"
otherId
"
:
"
bar
"
})
.
push
(
function
(
result
)
{
equal
(
result
,
"
42
"
);
})
.
push
(
undefined
,
function
(
error
)
{
ok
(
false
,
error
);
})
.
always
(
function
()
{
start
();
});
});
test
(
"
post with sub_id mapped and in doc
"
,
function
()
{
stop
();
expect
(
3
);
var
jio
=
jIO
.
createJIO
({
type
:
"
mapping
"
,
mapping_dict
:
{
"
otherId
"
:
[
"
equalSubId
"
]},
sub_storage
:
{
type
:
"
mappingstorage2713
"
}
});
Storage2713
.
prototype
.
put
=
function
(
id
,
doc
)
{
deepEqual
(
doc
,
{
"
title
"
:
"
foo
"
},
"
put 2713 called
"
);
equal
(
id
,
"
bar
"
,
"
put 2713 called
"
);
return
"
bar
"
;
};
jio
.
post
({
"
title
"
:
"
foo
"
,
"
otherId
"
:
"
bar
"
})
.
push
(
function
(
result
)
{
equal
(
result
,
"
bar
"
);
})
.
push
(
undefined
,
function
(
error
)
{
ok
(
false
,
error
);
})
.
always
(
function
()
{
start
();
});
});
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
// mappingStorage.putAttachment
// mappingStorage.putAttachment
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
...
@@ -1150,7 +1209,7 @@
...
@@ -1150,7 +1209,7 @@
"
doc
"
:
{}
"
doc
"
:
{}
}
}
],
],
"
total_rows
"
:
1
"
total_rows
"
:
2
}
}
},
"
allDocs check
"
);
},
"
allDocs check
"
);
})
})
...
...
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