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
1b04d350
Commit
1b04d350
authored
Jan 13, 2017
by
Hardik Juneja
Committed by
Hardik Juneja
Jan 18, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add hasCapacityMethod Function and fix related tests
parent
a7ee771f
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
120 additions
and
4 deletions
+120
-4
src/jio.storage/erp5storage.js
src/jio.storage/erp5storage.js
+1
-1
src/jio.storage/replicatestorage.js
src/jio.storage/replicatestorage.js
+1
-1
test/jio.storage/replicatestorage.tests.js
test/jio.storage/replicatestorage.tests.js
+118
-2
No files found.
src/jio.storage/erp5storage.js
View file @
1b04d350
...
...
@@ -447,7 +447,7 @@
ERP5Storage
.
prototype
.
hasCapacity
=
function
(
name
)
{
return
((
name
===
"
list
"
)
||
(
name
===
"
query
"
)
||
(
name
===
"
select
"
)
||
(
name
===
"
limit
"
)
||
(
name
===
"
sort
"
));
(
name
===
"
sort
"
))
||
(
name
===
"
allow_bulk
"
)
;
};
function
isSingleLocalRoles
(
parsed_query
)
{
...
...
src/jio.storage/replicatestorage.js
View file @
1b04d350
...
...
@@ -479,7 +479,7 @@
// Keep it like this until the bulk API is stabilized
var
use_bulk_get
=
false
;
try
{
use_bulk_get
=
context
.
_remote_sub_storage
.
hasCapacity
(
"
bulk
"
);
use_bulk_get
=
context
.
_remote_sub_storage
.
hasCapacity
(
"
allow_
bulk
"
);
}
catch
(
error
)
{
if
(
!
((
error
instanceof
jIO
.
util
.
jIOError
)
&&
(
error
.
status_code
===
501
)))
{
...
...
test/jio.storage/replicatestorage.tests.js
View file @
1b04d350
...
...
@@ -2486,7 +2486,10 @@
Storage200Bulk
.
prototype
.
put
=
function
()
{
return
this
.
_sub_storage
.
put
.
apply
(
this
.
_sub_storage
,
arguments
);
};
Storage200Bulk
.
prototype
.
hasCapacity
=
function
()
{
Storage200Bulk
.
prototype
.
hasCapacity
=
function
(
name
)
{
if
(
name
===
"
allow_bulk
"
)
{
return
true
;
}
return
this
.
_sub_storage
.
hasCapacity
.
apply
(
this
.
_sub_storage
,
arguments
);
};
Storage200Bulk
.
prototype
.
buildQuery
=
function
()
{
...
...
@@ -2566,7 +2569,10 @@
Storage200Bulk
.
prototype
.
put
=
function
()
{
return
this
.
_sub_storage
.
put
.
apply
(
this
.
_sub_storage
,
arguments
);
};
Storage200Bulk
.
prototype
.
hasCapacity
=
function
()
{
Storage200Bulk
.
prototype
.
hasCapacity
=
function
(
name
)
{
if
(
name
===
"
allow_bulk
"
)
{
return
true
;
}
return
this
.
_sub_storage
.
hasCapacity
.
apply
(
this
.
_sub_storage
,
arguments
);
};
Storage200Bulk
.
prototype
.
buildQuery
=
function
()
{
...
...
@@ -2637,4 +2643,114 @@
});
});
test
(
"
Donot bulk if substorage don't implement it
"
,
function
()
{
stop
();
expect
(
2
);
var
id
,
post_id
=
"
123456789
"
,
context
=
this
;
function
SubStorage200Bulk
()
{
return
;
}
function
Storage200Bulk
(
spec
)
{
this
.
_sub_storage
=
jIO
.
createJIO
(
spec
.
sub_storage
);
}
Storage200Bulk
.
prototype
.
bulk
=
function
(
args
)
{
deepEqual
(
args
,
[{
method
:
"
get
"
,
parameter_list
:
[
post_id
]
}]);
return
this
.
_sub_storage
.
bulk
(
args
);
};
Storage200Bulk
.
prototype
.
get
=
function
()
{
return
this
.
_sub_storage
.
get
.
apply
(
this
.
_sub_storage
,
arguments
);
};
Storage200Bulk
.
prototype
.
post
=
function
(
param
)
{
return
this
.
put
(
post_id
,
param
);
};
Storage200Bulk
.
prototype
.
put
=
function
()
{
return
this
.
_sub_storage
.
put
.
apply
(
this
.
_sub_storage
,
arguments
);
};
Storage200Bulk
.
prototype
.
hasCapacity
=
function
()
{
return
this
.
_sub_storage
.
hasCapacity
.
apply
(
this
.
_sub_storage
,
arguments
);
};
Storage200Bulk
.
prototype
.
buildQuery
=
function
()
{
return
this
.
_sub_storage
.
buildQuery
.
apply
(
this
.
_sub_storage
,
arguments
);
};
jIO
.
addStorage
(
'
replicatestorage200nobulk
'
,
Storage200Bulk
);
SubStorage200Bulk
.
prototype
.
get
=
function
()
{
return
{
title
:
"
bar
"
};
};
SubStorage200Bulk
.
prototype
.
post
=
function
(
param
)
{
return
this
.
put
(
post_id
,
param
);
};
SubStorage200Bulk
.
prototype
.
put
=
function
()
{
return
post_id
;
};
SubStorage200Bulk
.
prototype
.
hasCapacity
=
function
(
name
)
{
if
(
name
===
"
allow_bulk
"
)
{
return
false
;
}
return
true
;
};
SubStorage200Bulk
.
prototype
.
buildQuery
=
function
()
{
return
[{
id
:
"
123456789
"
,
value
:
{
"
title
"
:
"
bar
"
}}];
};
jIO
.
addStorage
(
'
replicatesubstorage200nobulk
'
,
SubStorage200Bulk
);
this
.
jio
=
jIO
.
createJIO
({
type
:
"
replicate
"
,
local_sub_storage
:
{
type
:
"
memory
"
},
remote_sub_storage
:
{
type
:
"
replicatestorage200nobulk
"
,
sub_storage
:
{
type
:
"
replicatesubstorage200nobulk
"
}
}
});
context
.
jio
.
__storage
.
_remote_sub_storage
.
post
({
"
title
"
:
"
bar
"
})
.
then
(
function
(
result
)
{
id
=
result
;
return
context
.
jio
.
repair
();
})
.
then
(
function
()
{
return
context
.
jio
.
get
(
id
);
})
.
then
(
function
(
result
)
{
deepEqual
(
result
,
{
title
:
"
bar
"
});
})
.
then
(
function
()
{
return
context
.
jio
.
__storage
.
_signature_sub_storage
.
get
(
id
);
})
.
then
(
function
(
result
)
{
deepEqual
(
result
,
{
hash
:
"
6799f3ea80e325b89f19589282a343c376c1f1af
"
});
})
.
fail
(
function
(
error
)
{
ok
(
false
,
error
);
})
.
always
(
function
()
{
start
();
});
});
}(
jIO
,
QUnit
));
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