Commit ddf61098 authored by Vincent Bechu's avatar Vincent Bechu Committed by Vincent Bechu

[test] Add scenarii to test and update saferepair storage to pass them

parent 5d6e60dd
/*global console, btoa, Blob*/
/*global console, btoa, Blob, RSVP*/
/*jslint nomen: true, maxlen: 200*/
(function (window, QUnit, jIO, rJS) {
"use strict";
......@@ -8,175 +8,21 @@
ok = QUnit.ok,
stop = QUnit.stop,
start = QUnit.start,
deepEqual = QUnit.deepEqual;
module = QUnit.module,
deepEqual = QUnit.deepEqual,
global = {defer: RSVP.defer()};
rJS(window)
.ready(function (g) {
///////////////////////////
// Local storage
///////////////////////////
// return g.run({
// type: "query",
// sub_storage: {
// type: "uuid",
// sub_storage: {
// type: "document",
// document_id: "/",
// sub_storage: {
// type: "zip",
// sub_storage: {
// type: "local"
// }
// }
// }
// }
// });
///////////////////////////
// Memory storage
///////////////////////////
return g.run({
type: "query",
sub_storage: {
type: "uuid",
sub_storage: {
type: "union",
storage_list: [{
type: "memory"
}]
}
}
});
///////////////////////////
// WebSQL storage
///////////////////////////
// return g.run({
// type: "query",
// sub_storage: {
// type: "uuid",
// sub_storage: {
// "type": "websql",
// "database": "test"
// }
// }
// });
///////////////////////////
// IndexedDB storage
///////////////////////////
// return g.run({
// type: "query",
// sub_storage: {
// type: "uuid",
// sub_storage: {
// "type": "indexeddb",
// "database": "test"
// }
// }
// });
///////////////////////////
// DAV storage
///////////////////////////
// return g.run({
// type: "query",
// sub_storage: {
// type: "uuid",
// sub_storage: {
// type: "drivetojiomapping",
// sub_storage: {
// "type": "dav",
// "url": "DAVURL",
// "basic_login": btoa("LOGIN:PASSWD")
// }
// }
// }
// });
///////////////////////////
// Dropbox storage
///////////////////////////
// return g.run({
// type: "query",
// sub_storage: {
// type: "uuid",
// sub_storage: {
// type: "drivetojiomapping",
// sub_storage: {
// "type": "dropbox",
// "access_token" : "TOKEN",
// "root" : "dropbox"
// }
// }
// }
// });
///////////////////////////
// Qiniu storage
///////////////////////////
// return g.run({
// type: "query",
// sub_storage: {
// type: "uuid",
// sub_storage: {
// "type": "qiniu",
// "bucket": "BUCKET",
// "access_key": "ACCESSKEY",
// "secret_key": "SECRETKEY"
// }
// }
// });
///////////////////////////
// Replicate storage
///////////////////////////
// return g.run({
// type: "query",
// sub_storage: {
// type: "uuid",
// sub_storage: {
// type: "replicate",
// local_sub_storage: {
// type: "memory"
// },
// remote_sub_storage: {
// "type": "memory"
// }
// }
// }
// });
///////////////////////////
// Crypt storage
///////////////////////////
// return g.run({
// type: "query",
// sub_storage: {
// type: "uuid",
// sub_storage: {
// type: "crypt",
// key: {"alg": "A256GCM", "ext": true,
// "k": "seeaLzpu8dHG07bO2ANH2GywbTqs_zrs4Vq8zmtYeE4",
// "key_ops": ["encrypt", "decrypt"], "kty": "oct"},
// sub_storage: {
// type: "indexeddb",
// database: "test427"
// }
// }
// }
// });
.ready(function () {
global.gadget = this;
global.defer.resolve();
})
.declareMethod('run', function (jio_options) {
test('Test "' + jio_options.type + '"scenario', function () {
var jio;
stop();
expect(14);
try {
jio = jIO.createJIO(jio_options);
......@@ -336,6 +182,223 @@
start();
});
});
module("scenario");
///////////////////////////
// Memory storage
///////////////////////////
test('Test Memory Storage scenario', function () {
stop();
expect(14);
return global.defer.promise
.then(function () {
return global.gadget.run({
type: "query",
sub_storage: {
type: "uuid",
sub_storage: {
type: "union",
storage_list: [{
type: "memory"
}]
}
}
});
});
});
///////////////////////////
// Local storage
///////////////////////////
test('Test Local Storage scenario', function () {
stop();
expect(14);
return global.defer.promise
.then(function () {
return global.gadget.run({
type: "query",
sub_storage: {
type: "uuid",
sub_storage: {
type: "document",
document_id: "/",
sub_storage: {
type: "zip",
sub_storage: {
type: "local"
}
}
}
}
});
});
});
///////////////////////////
// WebSQL storage
///////////////////////////
test('Test WebSQL Storage scenario', function () {
stop();
expect(14);
return global.defer.promise
.then(function () {
return global.gadget.run({
type: "query",
sub_storage: {
type: "uuid",
sub_storage: {
"type": "websql",
"database": "test"
}
}
});
});
});
///////////////////////////
// IndexedDB storage
///////////////////////////
test('Test IndexedDB Storage scenario', function () {
stop();
expect(14);
return global.defer.promise
.then(function () {
return global.gadget.run({
type: "query",
sub_storage: {
type: "uuid",
sub_storage: {
"type": "indexeddb",
"database": "test"
}
}
});
});
});
///////////////////////////
// DAV storage
///////////////////////////
test('Test DAV Storage scenario', function () {
stop();
expect(14);
return global.defer.promise
.then(function () {
return global.gadget.run({
type: "query",
sub_storage: {
type: "uuid",
sub_storage: {
type: "drivetojiomapping",
sub_storage: {
"type": "dav",
"url": "DAVURL",
"basic_login": btoa("LOGIN:PASSWD")
}
}
}
});
});
});
///////////////////////////
// Dropbox storage
///////////////////////////
test('Test Dropbox Storage scenario', function () {
stop();
expect(14);
return global.defer.promise
.then(function () {
return global.gadget.run({
type: "query",
sub_storage: {
type: "uuid",
sub_storage: {
type: "drivetojiomapping",
sub_storage: {
"type": "dropbox",
"access_token" : "TOKEN",
"root" : "dropbox"
}
}
}
});
});
});
///////////////////////////
// Qiniu storage
///////////////////////////
/*
test('Test Qiniu Storage scenario', function () {
stop();
expect(14);
return global.defer.promise
.then(function () {
return global.gadget.run({
type: "query",
sub_storage: {
type: "uuid",
sub_storage: {
"type": "qiniu",
"bucket": "BUCKET",
"access_key": "ACCESSKEY",
"secret_key": "SECRETKEY"
}
}
});
});
});
*/
///////////////////////////
// Replicate storage
///////////////////////////
test('Test Replicate Storage scenario', function () {
stop();
expect(14);
return global.defer.promise
.then(function () {
return global.gadget.run({
type: "query",
sub_storage: {
type: "uuid",
sub_storage: {
type: "replicate",
local_sub_storage: {
type: "memory"
},
remote_sub_storage: {
"type": "memory"
}
}
}
});
});
});
///////////////////////////
// Crypt storage
///////////////////////////
test('Test Crypt Storage scenario', function () {
stop();
expect(14);
return global.defer.promise
.then(function () {
return global.gadget.run({
type: "query",
sub_storage: {
type: "uuid",
sub_storage: {
type: "crypt",
key: {"alg": "A256GCM", "ext": true,
"k": "seeaLzpu8dHG07bO2ANH2GywbTqs_zrs4Vq8zmtYeE4",
"key_ops": ["encrypt", "decrypt"], "kty": "oct"},
sub_storage: {
type: "indexeddb",
database: "test427"
}
}
}
});
});
});
}(window, QUnit, jIO, rJS));
}(window, QUnit, jIO, rJS, RSVP));
......@@ -12,13 +12,8 @@
module = QUnit.module,
ATTACHMENT = 'data',
i,
<<<<<<< HEAD
name_list = ['get', 'post', 'put', 'buildQuery',
=======
name_list = ['get', 'post', 'put', 'remove', 'buildQuery',
>>>>>>> 7ed9424... Scenario: init officejs scenario
'putAttachment', 'getAttachment', 'allAttachments'];
///////////////////////////////////////////////////////
// Fake Storage
///////////////////////////////////////////////////////
......@@ -154,11 +149,8 @@
check_remote_attachment_creation: true,
check_remote_attachment_deletion: true,
check_local_deletion: false,
<<<<<<< HEAD
parallel_operation_amount: 10,
parallel_operation_attachment_amount: 10,
=======
>>>>>>> 7ed9424... Scenario: init officejs scenario
local_sub_storage: {
type: "query",
sub_storage: {
......
/*jslint nomen: true*/
(function (jIO) {
/*jslint indent:2,maxlen:80,nomen:true*/
/*global jIO, RSVP*/
(function (jIO, RSVP) {
"use strict";
/**
......@@ -88,4 +89,4 @@
jIO.addStorage('saferepair', SafeRepairStorage);
}(jIO));
}(jIO, RSVP));
......@@ -53,6 +53,11 @@
<script src="jio.storage/zipstorage.tests.js"></script>
<script src="jio.storage/gdrivestorage.tests.js"></script>
<script src="jio.storage/websqlstorage.tests.js"></script>
<script src="../node_modules/renderjs/dist/renderjs-latest.js"></script>
<script src="../examples/scenario.js"></script>
<script src="../examples/scenario_officejs.js"></script>
<!--script src="../lib/jquery/jquery.min.js"></script>
<script src="../src/jio.storage/xwikistorage.js"></script>
<script src="jio.storage/xwikistorage.tests.js"></script-->
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment