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
332b7754
Commit
332b7754
authored
Aug 29, 2013
by
Tristan Cavelier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
jio localstorage check & repair async tests added
parent
e4ee58ba
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
229 additions
and
0 deletions
+229
-0
test/jio.storage/localstorage.asynctests.js
test/jio.storage/localstorage.asynctests.js
+229
-0
No files found.
test/jio.storage/localstorage.asynctests.js
View file @
332b7754
...
...
@@ -644,4 +644,233 @@
});
test
(
"
Check & Repair
"
,
function
()
{
expect
(
17
);
var
o
=
{},
jio
=
jIO
.
createJIO
({
"
type
"
:
"
local
"
,
"
username
"
:
"
urepair
"
,
"
application_name
"
:
"
arepair
"
},
{
"
workspace
"
:
{}
});
stop
();
jIO
.
Promise
.
execute
(
function
()
{
o
.
putCorruptedDocuments
=
function
()
{
// put a document with a wrong attachment reference
util
.
json_local_storage
.
setItem
(
"
jio/localstorage/urepair/arepair/war
"
,
{
"
_id
"
:
"
war
"
,
"
title
"
:
"
b
"
,
"
_attachments
"
:
{
"
aa
"
:
{}}}
);
// put a document with a wrong metadata
util
.
json_local_storage
.
setItem
(
"
jio/localstorage/urepair/arepair/meta
"
,
{
"
_id
"
:
"
meta
"
,
"
title
"
:
[
"
b
"
,
[
"
c
"
,
{}],
{
"
blue
"
:
"
blue
"
}]}
);
// put a corrupted document
util
.
json_local_storage
.
setItem
(
"
jio/localstorage/urepair/arepair/cor
"
,
"
blue
"
);
// put an unreferenced attachment
util
.
json_local_storage
.
setItem
(
"
jio/localstorage/urepair/arepair/unref/aa
"
,
"
attachment content
"
);
};
o
.
putCorruptedDocuments
();
return
jIO
.
Promise
.
all
([
jio
.
check
({
"
_id
"
:
"
war
"
}),
jio
.
check
({
"
_id
"
:
"
meta
"
}),
jio
.
check
({
"
_id
"
:
"
cor
"
}),
jio
.
check
({
"
_id
"
:
"
inexistent
"
})
]);
}).
always
(
function
(
answers
)
{
deepEqual
(
answers
[
0
],
{
"
error
"
:
"
conflict
"
,
"
id
"
:
"
war
"
,
"
message
"
:
"
Attachment
\"
aa
\"
of
\"
war
\"
is missing
"
,
"
method
"
:
"
check
"
,
"
reason
"
:
"
missing attachment
"
,
"
result
"
:
"
error
"
,
"
status
"
:
409
,
"
statusText
"
:
"
Conflict
"
},
"
Check a document with one missing attachment
"
);
deepEqual
(
answers
[
1
],
{
"
error
"
:
"
conflict
"
,
"
id
"
:
"
meta
"
,
"
message
"
:
"
Some metadata might be lost
"
,
"
method
"
:
"
check
"
,
"
reason
"
:
"
corrupted
"
,
"
result
"
:
"
error
"
,
"
status
"
:
409
,
"
statusText
"
:
"
Conflict
"
},
"
Check document with wrong metadata
"
);
deepEqual
(
answers
[
2
],
{
"
error
"
:
"
conflict
"
,
"
id
"
:
"
cor
"
,
"
message
"
:
"
Document is unrecoverable
"
,
"
method
"
:
"
check
"
,
"
reason
"
:
"
corrupted
"
,
"
result
"
:
"
error
"
,
"
status
"
:
409
,
"
statusText
"
:
"
Conflict
"
},
"
Check corrupted document
"
);
deepEqual
(
answers
[
3
],
{
"
id
"
:
"
inexistent
"
,
"
method
"
:
"
check
"
,
"
result
"
:
"
success
"
,
"
status
"
:
200
,
"
statusText
"
:
"
Ok
"
},
"
Check inexistent document
"
);
}).
then
(
function
()
{
return
jIO
.
Promise
.
all
([
jio
.
repair
({
"
_id
"
:
"
war
"
}),
jio
.
repair
({
"
_id
"
:
"
meta
"
}),
jio
.
repair
({
"
_id
"
:
"
cor
"
}),
jio
.
repair
({
"
_id
"
:
"
inexistent
"
})
]);
}).
always
(
function
(
answers
)
{
deepEqual
(
answers
[
0
],
{
"
id
"
:
"
war
"
,
"
method
"
:
"
repair
"
,
"
result
"
:
"
success
"
,
"
status
"
:
200
,
"
statusText
"
:
"
Ok
"
},
"
Repair a document with one missing attachment
"
);
deepEqual
(
answers
[
1
],
{
"
id
"
:
"
meta
"
,
"
method
"
:
"
repair
"
,
"
result
"
:
"
success
"
,
"
status
"
:
200
,
"
statusText
"
:
"
Ok
"
},
"
Repair document with wrong metadata
"
);
deepEqual
(
answers
[
2
],
{
"
id
"
:
"
cor
"
,
"
method
"
:
"
repair
"
,
"
result
"
:
"
success
"
,
"
status
"
:
200
,
"
statusText
"
:
"
Ok
"
},
"
Repair corrupted document
"
);
deepEqual
(
answers
[
3
],
{
"
id
"
:
"
inexistent
"
,
"
method
"
:
"
repair
"
,
"
result
"
:
"
success
"
,
"
status
"
:
200
,
"
statusText
"
:
"
Ok
"
},
"
Repair inexistent document
"
);
}).
then
(
function
()
{
o
.
getCorruptedDocuments
=
function
()
{
return
jIO
.
Promise
.
all
([
jio
.
get
({
"
_id
"
:
"
war
"
}),
jio
.
get
({
"
_id
"
:
"
meta
"
}),
jio
.
get
({
"
_id
"
:
"
cor
"
}),
jio
.
get
({
"
_id
"
:
"
inexistent
"
})
]);
};
return
o
.
getCorruptedDocuments
();
}).
always
(
function
(
answers
)
{
o
.
testGetAnswers
=
function
(
answers
)
{
deepEqual
(
answers
[
0
],
{
"
data
"
:
{
"
_id
"
:
"
war
"
,
"
title
"
:
"
b
"
},
"
id
"
:
"
war
"
,
"
method
"
:
"
get
"
,
"
result
"
:
"
success
"
,
"
status
"
:
200
,
"
statusText
"
:
"
Ok
"
},
"
Get repaired document with one missing attachment
"
);
deepEqual
(
answers
[
1
],
{
"
data
"
:
{
"
_id
"
:
"
meta
"
,
"
title
"
:
"
b
"
},
"
id
"
:
"
meta
"
,
"
method
"
:
"
get
"
,
"
result
"
:
"
success
"
,
"
status
"
:
200
,
"
statusText
"
:
"
Ok
"
},
"
Get repaired document with wrong metadata
"
);
deepEqual
(
answers
[
2
],
{
"
error
"
:
"
not_found
"
,
"
id
"
:
"
cor
"
,
"
message
"
:
"
Cannot find document
"
,
"
method
"
:
"
get
"
,
"
reason
"
:
"
missing
"
,
"
result
"
:
"
error
"
,
"
status
"
:
404
,
"
statusText
"
:
"
Not Found
"
},
"
Get repaired corrupted document
"
);
deepEqual
(
answers
[
3
],
{
"
error
"
:
"
not_found
"
,
"
id
"
:
"
inexistent
"
,
"
message
"
:
"
Cannot find document
"
,
"
method
"
:
"
get
"
,
"
reason
"
:
"
missing
"
,
"
result
"
:
"
error
"
,
"
status
"
:
404
,
"
statusText
"
:
"
Not Found
"
},
"
Get repaired inexistent document
"
);
};
o
.
testGetAnswers
(
answers
);
}).
then
(
function
()
{
o
.
putCorruptedDocuments
();
return
jio
.
repair
({});
}).
always
(
function
(
answer
)
{
deepEqual
(
answer
,
{
"
method
"
:
"
repair
"
,
"
result
"
:
"
success
"
,
"
status
"
:
200
,
"
statusText
"
:
"
Ok
"
},
"
Repair all the database
"
);
}).
then
(
function
()
{
return
o
.
getCorruptedDocuments
();
}).
always
(
function
(
answers
)
{
o
.
testGetAnswers
(
answers
);
}).
always
(
start
);
});
}));
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