Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (function() {
- 'use strict';
- var plugin = window.kontur.plugin;
- var tests = plugin.tests;
- var Promise = window.ES6Promise.Promise;
- function assert (expected) {
- return tests.send({
- type: 'hash.md5',
- source: {
- type: 'file',
- path: tests.getSampleFile('drive')
- },
- sink: {type: 'hex'}
- }).then(function(result) {
- expect(result.type).to.equal('hex');
- expect(result.data).to.equal(expected);
- });
- }
- function funcDrive2(options) {
- return new Promise(function(resolve) {
- var countValue = Math.floor(options.size / options.pieces);
- var sourceOffsetValues = Array();
- var mode;
- for (var i = 0; i <= options.pieces; i++) {
- sourceOffsetValues.push(i * countValue);
- }
- sourceOffsetValues.reduce(function(promise, sourceOffsetValue) {
- return promise.then(function() {
- return tests.send({
- type: 'io.transfer',
- source: options.testData,
- sink: options.sink,
- sourceOffset: sourceOffsetValue,
- count: countValue
- });
- }).then(function(result) {
- return tests.send({
- type: 'archive.gzip',
- source: result,
- sink: options.secondsink
- });
- }).then(function(result) {
- return tests.send({
- type: 'archive.ungzip',
- source: result,
- sink: options.sink
- });
- }).then(function(result) {
- if (sourceOffsetValue === 0) {
- mode = 'create';
- } else {
- mode = 'open';
- }
- return tests.send({
- type: 'io.transfer',
- source: result,
- sink: {
- type: 'file',
- path: tests.getSampleFile('drive'),
- mode: mode,
- access: 'readWrite'
- },
- sinkOffset: sourceOffsetValue
- });
- }).then(function(result){
- resolve(result);
- });
- }, Promise.resolve());
- });
- }
- describe('Drive', function() {
- it('Drive with small file, 2 pieces (base64)', function() {
- funcDrive2({
- testData: {
- type: 'file',
- path: tests.getSampleFile('medium')
- },
- sink: {
- type: 'base64'
- },
- secondsink: {
- type: 'base64'
- },
- mode: 'openOrCreate',
- size: 1481643 ,
- pieces: 2
- }).then(function() {
- setTimeout(function() {
- assert('a39827b88fb33a4074f310625560bc86');
- }, 10000);
- });
- });
- });
- }());
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement