var asn1 = require('asn1');


///--- Globals

var BerReader = asn1.BerReader;
var BerWriter = asn1.BerWriter;
var AddResponse;


///--- Tests

test('load library', function (t) {
  AddResponse = require('../../lib/index').AddResponse;
  t.ok(AddResponse);
  t.end();
});


test('new no args', function (t) {
  t.ok(new AddResponse());
  t.end();
});


test('new with args', function (t) {
  var res = new AddResponse({
    messageID: 123,
    status: 0
  });
Beispiel #2
0
var baseURL = config.baseUrl;
var sdk = require('hook.io-sdk');
var startDevCluster = require('../lib/helpers/startDevCluster');
var metric = require('../../lib/resources/metric');

var testUser = config.testUsers.david;

var client = sdk.createClient(testUser.hookSdk);

tap.test('start the dev cluster', function (t) {
  startDevCluster({
    flushRedis: true,
    flushTestUsers: true
  }, function (err) {
    t.pass('cluster started');
    // should not require a timeout, probably issue with one of the services starting
    // this isn't a problem in production since these services are intended to start independant of each other
    setTimeout(function(){
      t.end();
    }, 2000);
  });
});

// create a few new hooks to test
tap.test('attempt to create a new hook with delay - authorized api key', function (t) {
  client.hook.create({ 
    "name": "test-hook-delay",
    "source": 'sleep 1;\necho "hello";',
    "language": "bash"
  }, function (err, res) {
    t.error(err);
Beispiel #3
0
var getProcessedSettings = function (processed, settings) {
	return settings.two + ' > ' + processed();
}
var getOne = function () {
	return 1;
}


var Wiretree = require('..');

test('resolve:: throws error on missing dependencies', function (t) {
  var tree = new Wiretree();
  tree
  .add('plugin', plugin)
  .then(function () {
    t.throws(function () {
      tree.resolve();
    }, /Can't find tree dependencies: mod/);
    t.end();
  });
});


test('resolve:: resolve all regular tree dependencies before call callback', function (t) {
  var tree = new Wiretree();

  tree
  .add('mod', mod)
  .add('plugin', plugin)
  .resolve(function () {
    t.ok(tree.plugins.plugin.res);
Beispiel #4
0
tape.test('Compile JS', (t) => {
  let resultFilePath

  exec('rm -rf fixtures/build/assets fixtures/build/manifests/javascript.json')
  .then(() => {
    return exec('node ../bin/compile-js.js', {
      cwd: 'fixtures'
    })
  }).then(() => {
    return readFile('fixtures/build/manifests/javascript.json')
  }).then((data) => {
    let assetPathPattern = /^\/assets\/(sandbox-.*\.js)$/
    let resultDeliveryPath = JSON.parse(data)['sandbox.js']
    t.ok(assetPathPattern.test(resultDeliveryPath), 'the resulting path in the manifest should be well formed')
    let resultFileName = assetPathPattern.exec(resultDeliveryPath)[1]
    resultFilePath = `fixtures/build/assets/javascripts/${resultFileName}`
    return readFile(resultFilePath)
  }).then((rawJS) => {
    let js = rawJS.toString()
    t.notOk(js.includes('=>'), 'the resulting JS should not contain any arrow functions')
    t.notOk(js.includes('`'), 'the resulting JS should not contain any template strings')
    return exec(`node ${resultFilePath}`)
  }).then((stdout) => {
    t.equal(stdout, 'Hello world\n', 'the resulting JS should log `Hello World`')
    t.end()
  }).catch((err) => {
    t.error(err)
  })
})
Beispiel #5
0
tape.test("path", function(test) {

    test.ok(path.isAbsolute("X:\\some\\path\\file.js"), "should identify absolute windows paths");
    test.ok(path.isAbsolute("/some/path/file.js"), "should identify absolute unix paths");

    test.notOk(path.isAbsolute("some\\path\\file.js"), "should identify relative windows paths");
    test.notOk(path.isAbsolute("some/path/file.js"), "should identify relative unix paths");

    var paths = [
        {
            actual: "X:\\some\\..\\.\\path\\\\file.js",
            normal: "X:/path/file.js",
            resolve: {
                origin: "X:/path/origin.js",
                expected: "X:/path/file.js"
            }
        }, {
            actual: "some\\..\\.\\path\\\\file.js",
            normal: "path/file.js",
            resolve: {
                origin: "X:/path/origin.js",
                expected: "X:/path/path/file.js"
            }
        }, {
            actual: "/some/.././path//file.js",
            normal: "/path/file.js",
            resolve: {
                origin: "/path/origin.js",
                expected: "/path/file.js"
            }
        }, {
            actual: "some/.././path//file.js",
            normal: "path/file.js",
            resolve: {
                origin: "",
                expected: "path/file.js"
            }
        }, {
            actual: ".././path//file.js",
            normal: "../path/file.js"
        }, {
            actual: "/.././path//file.js",
            normal: "/path/file.js"
        }
    ];

    paths.forEach(function(p) {
        test.equal(path.normalize(p.actual), p.normal, "should normalize " + p.actual);
        if (p.resolve) {
            test.equal(path.resolve(p.resolve.origin, p.actual), p.resolve.expected, "should resolve " + p.actual);
            test.equal(path.resolve(p.resolve.origin, p.normal, true), p.resolve.expected, "should resolve " + p.normal + " (already normalized)");
        }
    });

    test.end();
});
Beispiel #6
0
/**
 * Test suite
 *
 * @package transformit
 * @author drk <*****@*****.**>
 */

/**
 * Dependencies
 */
var test    = require('tape').test;

var fetchBoredInstance = require('../lib/bored-instance.js');

test('bored instance', function (t) {
    t.plan(1);

    fetchBoredInstance('http://api2.transloadit.com', function (err, instance) {
        t.ok(instance, 'Returned a string');
    });
});
Beispiel #7
0
var tape = require("tape");

var protobuf = require("..");

tape.test("comments", function(test) {
    protobuf.load("tests/data/comments.proto", function(err, root) {
        if (err)
            throw test.fail(err.message);

        test.equal(root.lookup("Test1").comment, "Message\nwith\na\ncomment.", "should parse /**-blocks");
        test.equal(root.lookup("Test2").comment, null, "should not parse //-blocks");
        test.equal(root.lookup("Test3").comment, null, "should not parse /*-blocks");

        test.equal(root.lookup("Test1.field1").comment, "Field with a comment.", "should parse blocks for message fields");
        test.equal(root.lookup("Test1.field2").comment, null, "should not parse lines for message fields");
        test.equal(root.lookup("Test1.field3").comment, "Field with a comment.", "should parse triple-slash lines for message fields");

        test.equal(root.lookup("Test3").comments.ONE, "Value with a comment.", "should parse blocks for enum values");
        test.equal(root.lookup("Test3").comments.TWO, null, "should not parse lines for enum values");
        test.equal(root.lookup("Test3").comments.THREE, "Value with a comment.", "should parse triple-slash lines for enum values");

        test.end();
    });
});
var tape = require("tape");

var protobuf = require("..");

var def = {
    keyType: "bytes",
    type: "string",
    id: 1
};

tape.test("reflected map fields", function(test) {

    var field = protobuf.MapField.fromJSON("a", def);
    test.same(field.toJSON(), def, "should construct from and convert back to JSON");

    test.throws(function() {
        field.resolve();
    }, Error, "should throw for invalid key types");

    test.end();
});
Beispiel #9
0
import {test} from 'tape';
import * as gt from '../';


test("version matches package.json", (t) => {
    t.equal(gt.version, require("../package.json").version);
    t.end();
});

Beispiel #10
0
var test = require('tape').test;
var plugin = require('../lib/plugin');


test('mock.html', function (t) {
    var pluginCount = 2;
    var count = 0;
    plugin.analyze('mock.html', function (state) {
        count++;

        t.assert(count <= pluginCount);
        if (count == pluginCount) {
            t.end();
        }
        t.equal(state.files.length, 1);
        t.equal(state.files[0].path, 'mock.html')
        t.assert(state.files[0].metadata.length)
    });
});
tape.test("oneofs", function(test) {
    var root = protobuf.parse(proto).root;

    var Message = root.lookup("Message");

    var message = Message.create({
        str: "a",
        num: 1,
        other: false
    });

    test.equal(message.num, 1, "should initialize the last value");
    test.equal(message.kind, "num", "should reference the last value");
    
    message.kind = 'num';
    test.notOk(message.hasOwnProperty('str'), "should delete other values");

    message.str = "a";
    message.kind = 'str';

    test.notOk(message.hasOwnProperty('num'), "should delete the previous value");
    test.equal(message.str, "a", "should set the new value");
    test.equal(message.kind, "str", "should reference the new value");

    message.num = 0; // default
    message.kind = 'num';
    test.notOk(message.hasOwnProperty('str'), "should delete the previous value");
    test.equal(message.num, 0, "should set the new value");
    test.equal(message.kind, "num", "should reference the new value");
    test.equal(message.hasOwnProperty("num"), true, "should have the new value on the instance, not just the prototype");

    delete message.other;
    var buf = Message.encode(message).finish();
    test.equal(buf.length, 2, "should write a total of 2 bytes");
    test.equal(buf[0], 16, "should write id 1, wireType 0");
    test.equal(buf[1], 0, "should write a value of 0");

    test.end();

});
Beispiel #12
0
var test = require("tape").test

var level = require("level-test")
var terminus = require("terminus")
var multibuffer = require("multibuffer")
var bufstream = require("../")

var db1, db2

test("setup", function (t) {
  db1 = level("source")()
  bufstream.rawReader(db1)
    .pipe(terminus.concat(function (contents) {
      t.notOk(contents.toString(), "Db should be empty")
      db1.put("foo", "bar")
      db1.put("blah", "zzzz")
      db1.put("kasdfa", "avasdfasdf")
      t.end()
    }))
})

test("read", function (t) {
  bufstream.rawReader(db1)
    .pipe(terminus.concat(function (contents) {
      t.ok(contents, "Now there is stuff")
      var parts = multibuffer.unpack(contents)
      t.equals(parts[0].toString(), "blah")
      t.equals(parts.length, 6, "3 key/value pairs")
      t.end()
    }))
})
Beispiel #13
0
var test = require('tape').test
var fs = require('../../chrome')

test('write', function (t) {
  fs.open('/test1.txt', 'w', function (err, fd) {
    t.notOk(err)
    fs.write(fd, new Buffer('hello world'), 0, 11, null, function (err, written, buf) {
      t.ok(!err)
      t.ok(buf, 'Buffer exists')
      t.same(written, 11)
      fs.close(fd, function () {
        fs.readFile('/test1.txt', 'utf-8', function (err, buf) {
          t.notOk(err)
          t.same(buf, 'hello world')
          fs.unlink('/test1.txt', function (err) {
            t.ok(!err, 'unlinked /test1.txt')
            t.end()
          })
        })
      })
    })
  })
})

test('write + partial', function (t) {
  fs.open('/testpartial.txt', 'w', function (err, fd) {
    t.notOk(err)
    fs.write(fd, new Buffer('hello'), 0, 5, null, function (err, written, buf) {
      t.notOk(err)
      fs.write(fd, new Buffer(' world'), 0, 6, null, function (err, written, buf) {
        t.ok(!err)
Beispiel #14
0
var test = require("tape").test
  , model = require("../model")
;

test("alert_repeat_frequency is configurable", function(t) {
  var original = model.Item.alert_repeat_frequency
    , modified = original + 3600
  ;
  model.configure({
    alert_repeat_frequency: modified
  });
  t.equal(model.Item.alert_repeat_frequency, modified, "alert_repeat_frequency should equal " + modified);
  t.end();
});

test("frequency controls whether overdue", function(t) {
  var redis = {}
    , freq = 100
    , info = {
      freq: freq,
      ts: Date.now() - ((freq + 10) * 1000)
    }
    , item = new model.Item(redis, info)
  ;

  t.ok(item.overdue(), "overdue after frequency seconds have passed since last update");

  info = {
    freq: freq,
    ts: Date.now() - ((freq - 1) * 1000)
Beispiel #15
0
test('encoding/decoding 32-bits float numbers', function (t) {
  var encoder = msgpack()
  var float32 = [
    1.5,
    0.15625,
    -2.5
  ]

  var float64 = [
    2 ** 150,
    1.337,
    2.2
  ]

  float64.forEach(function (num) {
    t.test('encoding ' + num, function (t) {
      var buf = encoder.encode(num)
      t.equal(buf.length, 9, 'must have 5 bytes')
      t.equal(buf[0], 0xcb, 'must have the proper header')

      var dec = buf.readDoubleBE(1)
      t.equal(dec, num, 'must decode correctly')
      t.end()
    })

    t.test('decoding ' + num, function (t) {
      var buf = Buffer.allocUnsafe(9)
      var dec
      buf[0] = 0xcb
      buf.writeDoubleBE(num, 1)

      dec = encoder.decode(buf)
      t.equal(dec, num, 'must decode correctly')
      t.end()
    })

    t.test('mirror test ' + num, function (t) {
      var dec = encoder.decode(encoder.encode(num))
      t.equal(dec, num, 'must decode correctly')
      t.end()
    })
  })

  float32.forEach(function (num) {
    t.test('encoding ' + num, function (t) {
      var buf = encoder.encode(num)
      t.equal(buf.length, 5, 'must have 5 bytes')
      t.equal(buf[0], 0xca, 'must have the proper header')

      var dec = buf.readFloatBE(1)
      t.equal(dec, num, 'must decode correctly')
      t.end()
    })

    t.test('forceFloat64 encoding ' + num, function (t) {
      var enc = msgpack({ forceFloat64: true })
      var buf = enc.encode(num)

      t.equal(buf.length, 9, 'must have 9 bytes')
      t.equal(buf[0], 0xcb, 'must have the proper header')

      var dec = buf.readDoubleBE(1)
      t.equal(dec, num, 'must decode correctly')
      t.end()
    })

    t.test('decoding ' + num, function (t) {
      var buf = Buffer.allocUnsafe(5)
      var dec
      buf[0] = 0xca
      buf.writeFloatBE(num, 1)

      dec = encoder.decode(buf)
      t.equal(dec, num, 'must decode correctly')
      t.end()
    })

    t.test('mirror test ' + num, function (t) {
      var dec = encoder.decode(encoder.encode(num))
      t.equal(dec, num, 'must decode correctly')
      t.end()
    })
  })

  t.end()
})
Beispiel #16
0
	'46H2406iAGE/rZcqeSjPbmcORXgCNNBlLJ0QQ= ' +
	'*****@*****.**';

var DSA_1024 = 'ssh-dss AAAAB3NzaC1kc3MAAACBAKK5sckoM05sOPajUcTWG0zPTvyRmj6' +
	'YQ1g2IgezUUrXgY+2PPy07+JrQi8SN9qr/CBP+0q0Ec48qVFf9LlkUBwu9Jf5HTUVNiKNj3c' +
	'SRPFH8HqZn+nxhVsOLhnHWxgDQ8OOm48Ma61NcYVo2B0Ne8cUs8xSqLqba2EG9ze87FQZAAA' +
	'AFQCVP/xpiAofZRD8L4QFwxOW9krikQAAAIACNv0EmKr+nIA13fjhpiqbYYyVXYOiWM4cmOD' +
	'G/d1J8/vR4YhWHWPbAEw7LD0DEwDIHLlRZr/1jsHbFcwt4tzRs95fyHzpucpGhocmjWx43qt' +
	'xEhDeJrxPlkIXHakciAEhoo+5YeRSSgRse5PrZDosdr5fA+DADs8tnto5Glf5owAAAIBHcEF' +
	'5ytvCRiKbsWKOgeMZ7JT/XGX+hMhS7aaJ2IspKj7YsWada1yBwoM6yYHtlpnGsq/PoPaZU8K' +
	'40f47psV6OhSh+/O/jgqLS/Ur2c0mQQqIb7vvkc7he/SPOQAqyDmyYFBuazuSf2s9Uy2hfvj' +
	'Wgb6X+vN9W8SOb2668IL7Vg== mark@bluesnoop.local';

test('rsa1024 key metadata', function(t) {
	var k = sshpk.parseKey(SSH_1024, 'ssh');
	t.equal(k.type, 'rsa');
	t.equal(k.size, 1024);
	t.end();
});

test('rsa1133 key metadata', function(t) {
	var k = sshpk.parseKey(SSH_1133, 'ssh');
	t.equal(k.type, 'rsa');
	t.equal(k.size, 1133);
	t.end();
});

test('dsa1024 key metadata', function(t) {
	var k = sshpk.parseKey(DSA_1024, 'ssh');
	t.equal(k.type, 'dsa');
	t.equal(k.size, 1024);
	t.end();
            t.ok(err, 'Provision should fail');
        }

        t.end();
    });
}


// --- Tests


test('Setup allowProvision without api',
function (t) {
    try {
        plugin.allowProvision();
    } catch (e) {
        t.equal(e.message, 'api (object) is required', 'err message');
        t.end();
    }
});


test('Setup allowProvision without cfg',
function (t) {
    try {
        plugin.allowProvision(API);
    } catch (e) {
        t.equal(e.message, 'cfg (object) is required', 'err message');
        t.end();
    }
});
Beispiel #18
0
var test = require('tape').test

test('prefixes', function (t) {
  var valid = [
    false, // if browser doesn't support it
    'fontSmoothing',
    'MozFontSmoothing',
    'WebkitFontSmoothing',
    'OFontSmoothing',
    'msFontSmoothing'
  ]

  var result = prefix('fontSmoothing')
  t.ok(valid.indexOf(result) !== -1, 'valid: returns ' + result)

  valid = [
    false, // if browser doesn't support it
    'transform',
    'MozTransform',
    'WebkitTransform',
    'OTransform',
    'msTransform'
  ]
  result = prefix('transform')
  t.ok(valid.indexOf(result) !== -1, 'valid: returns ' + result)

  t.equal(prefix('width'), 'width', 'does not prefix unless necessary')
  t.equal(prefix('foobarkashadasha'), false, 'returns false if prop is not supported')
  t.end()
})
Beispiel #19
0


///--- Tests

test('connect timeout', function (t) {
    function done() {
        client.removeAllListeners();
        client.close();
        t.end();
    }

    client = fast.createClient({
        host: TIMEOUT_HOST,
        port: PORT,
        connectTimeout: TIMEOUT_MS
    });
    var failTimer = setTimeout(function () {
        t.ok(false, 'timeout failed');
        done();
    }, TIMEOUT_MS * 2);
    client.once('connectError', function (err) {
        t.equal(err.name, 'ConnectionTimeoutError', 'timeout error');
        clearTimeout(failTimer);
        done();
    });
});

test('close suppress connectErrors', function (t) {
    client = fast.createClient({
        host: TIMEOUT_HOST,
        port: PORT,
Beispiel #20
0
var DNSServer = require('../../lib/dns-server');
var MockRedis = require('./mock-redis');

var utils = require('../../lib/utils');

var sandbox;
var redis;
var server;
var currentSerial = 1;

test('setup sandbox', function (t) {
	sandbox = sinon.sandbox.create();
	sandbox.stub(utils, 'nextSerial', function () {
		return (currentSerial + 1);
	});
	sandbox.stub(utils, 'currentSerial', function () {
		return (currentSerial);
	});
	t.equal(utils.currentSerial(), 1);
	redis = new MockRedis();
	t.end();
});

test('create basic dataset', function (t) {
	var s = new UpdateStream({
		client: redis,
		config: {
			forward_zones: {
				'foo': {}
			},
			reverse_zones: {}
		}
Beispiel #21
0
test('setup', function (t) {
    common.setup(function (_, clients, server) {
        CLIENTS = clients;
        CLIENT  = clients.user;
        OTHER   = clients.other;
        SERVER  = server;

        addPackage1();

        // Add custom packages; "sdc_" ones will be owned by admin user:
        function addPackage1() {
            addPackage(CLIENT, SDC_256_INACTIVE, function (err) {
                t.ifError(err, 'Add package error');

                addPackage2();
            });
        }

        function addPackage2() {
            addPackage(CLIENT, SDC_128_LINUX, function (err) {
                t.ifError(err, 'Add package error');

                addPackage3();
            });
        }

        function addPackage3() {
            addPackage(CLIENT, SDC_256, function (err) {
                t.ifError(err, 'Add package error');
                addPackage4();
            });
        }

        function addPackage4() {
            addPackage(CLIENT, SDC_512, function (err) {
                t.ifError(err, 'Add package error');
                t.end();
            });
        }
    });
});
Beispiel #22
0
var test = require('tape').test;
var generate = require('../index.js');

test("map type missing type key", function (t) {
  t.throws(function () {
    generate({
      t : {}
    });
  }, Error('Missing "type" Key in "t"'), 'should throw');
  t.end();
});

test("map type missing kind key", function (t) {
  t.throws(function () {
    generate({
      t : {type: 'map'}
    });
  }, Error('Map Requires "kind" Key in "t"'), 'should throw');
  t.end();
});

test("map type of kind string", function (t) {
  var types = generate({
    t : {type: 'map', kind: 'string'}
  });
  t.deepEqual(types.t.marshal({x: 'a'}), {x: 'a'}, 'should marshal map of string')
  t.end();
});
Beispiel #23
0
var asn1 = require('asn1');


///--- Globals

var BerReader = asn1.BerReader;
var BerWriter = asn1.BerWriter;
var Attribute;


///--- Tests

test('load library', function (t) {
  Attribute = require('../lib/index').Attribute;
  t.ok(Attribute);
  t.end();
});


test('new no args', function (t) {
  t.ok(new Attribute());
  t.end();
});


test('new with args', function (t) {
  var attr = new Attribute({
    type: 'cn',
    vals: ['foo', 'bar']
  });
Beispiel #24
0
var turf = require('turf');
var lines = require('./fixtures/lines.json');
var points = Array.prototype.concat.apply([], lines);

var ruler = createRuler(32.8351);
var milesRuler = createRuler(32.8351, 'miles');

function assertErr(t, actual, expected, maxErr, description) {
    if (isNaN(actual) || isNaN(expected)) t.fail(description + ' produced NaN');
    var err = Math.abs((actual - expected) / expected);
    if (err > maxErr) t.fail(description + ', err: ' + err);
}

test('cheapRuler constructor', function (t) {
    t.throws(function () {
        createRuler();
    }, 'errors without latitude');
    t.end();
});

test('distance', function (t) {
    for (var i = 0; i < points.length - 1; i++) {
        var expected = turf.distance(turf.point(points[i]), turf.point(points[i + 1]));
        var actual = ruler.distance(points[i], points[i + 1]);
        assertErr(t, expected, actual, 0.003, 'distance');
    }
    t.pass('distance within 0.3%');
    t.end();
});

test('bearing', function (t) {
    for (var i = 0; i < points.length - 1; i++) {
Beispiel #25
0
var test = require('tape').test;

var blogz = require('../');

var blog = blogz({
    domain      : 'example.com',
    contentDir  : __dirname + '/many-posts',
    latestCount : 20,
});

test(function(t) {
    t.equal(blog.posts.length, 50, 'There are 50 posts');
    t.equal(Object.keys(blog.post).length, 50, 'There are 50 in post');
    t.equal(blog.pages.length, 5, 'There is 5 pages page');
    t.equal(blog.latest.length, 20, 'There are 20 in latest');

    t.equal(Object.keys(blog.archive).length, 1, 'There is one yearly archive');
    t.equal(Object.keys(blog.archive['2013']).length, 1, 'There is one monthly archive');
    t.equal(Object.keys(blog.tagged).length, 50, 'There are 50 tags');

    t.end();
});
Beispiel #26
0
var test = require('tape').test;
var getOtherData = require('../index2').getOtherData;

test('getOtherData', function (troot) {

  test('returns the correct information', function (t) {
    var data = getOtherData();

    t.equal(data.a, 'A');
    t.equal(data.b, 'B');
    t.equal(data.c, 'C');

    t.end();
  });

  troot.end();

})
test('setup', function (t) {
    common.setup('~7.2', function (err, _client, _server) {
        t.ifError(err, 'common setup error');
        t.ok(_client, 'common _client ok');
        client = _client;
        account = client.account.login;
        A_ROLE_NAME = client.role.name;
        A_ROLE_UUID = client.role.id;
        A_POLICY_NAME = client.policy.name;
        subPrivateKey = client.subPrivateKey;
        SUB_KEY_ID = client.SUB_ID;
        if (!process.env.SDC_SETUP_TESTS) {
            t.ok(_server);
            server = _server;
        }
        saveKey(KEY, keyName, client, t, function () {
            // Add custom packages; "sdc_" ones will be owned by admin user:
            addPackage(client, sdc_128_ok, function (err2, entry) {
                t.ifError(err2, 'Add package error');
                sdc_128_ok_entry = entry;
                addPackage(client, sdc_256_inactive, function (err3, entry2) {
                    t.ifError(err3, 'Add package error');
                    sdc_256_inactive_entry = entry2;
                    t.end();
                });
            });
        });
    });
});
Beispiel #28
0
const t = require('tape');
const sc = require('skale').context();

const skip = process.env.AWS_ACCESS_KEY_ID ? false : true;

t.test('textFile s3 file', {skip: skip}, function (t) {
  t.plan(1);
  sc.textFile('s3://skale-test-eu-west-1/test/iris.csv')
    .count(function (err, res) {
      t.ok(res === 151);
    });
});

t.test('textFile s3 compressed file', {skip: skip}, function (t) {
  t.plan(1);
  sc.textFile('s3://skale-test-eu-west-1/test/iris.csv.gz')
    .count(function (err, res) {
      t.ok(res === 151);
    });
});

t.test('textFile s3 dir', {skip: skip}, function (t) {
  t.plan(1);
  sc.textFile('s3://skale-test-eu-west-1/test/split/')
    .count(function (err, res) {
      t.ok(res === 151);
    });
});

t.test('textFile s3 compressed dir', {skip: skip}, function (t) {
  t.plan(1);

// --- Tests

test('setup', function (t) {
    common.setup('~7.0', function (err, _client, _server) {
        t.ifError(err, 'common setup error');
        t.ok(_client, 'common _client ok');
        client = _client;
        if (!process.env.SDC_SETUP_TESTS) {
            t.ok(_server);
            server = _server;
        }
        saveKey(KEY, keyName, client, t, function () {
            // Add custom packages; "sdc_" ones will be owned by admin user:
            addPackage(client, sdc_128_ok, function (err2, entry) {
                t.ifError(err2, 'Add package error');
                sdc_128_ok_entry = entry;
                addPackage(client, sdc_256_inactive, function (err3, entry2) {
                    t.ifError(err3, 'Add package error');
                    sdc_256_inactive_entry = entry2;
                    t.end();
                });
            });
        });
    });
});


test('Get Headnode', function (t) {
    client.cnapi.listServers(function (err, servers) {
Beispiel #30
0
const t = require('tape');
const sc = require('skale').context();

t.test('cartesian', function (t) {
  const data = [1, 2, 3, 4, 5, 6];
  const data2 = [7, 8, 9, 10, 11, 12];
  const nPartitions = 3;

  const a = sc.parallelize(data, nPartitions);
  const b = sc.parallelize(data2, nPartitions);

  t.plan(1);

  a.cartesian(b)
    .collect(function(err, res) {
      res.sort();
      t.deepEqual(res, [
        [1, 10], [1, 11], [1, 12], [1, 7], [1, 8], [1, 9],
        [2, 10], [2, 11], [2, 12], [2, 7], [2, 8], [2, 9],
        [3, 10], [3, 11], [3, 12], [3, 7], [3, 8], [3, 9],
        [4, 10], [4, 11], [4, 12], [4, 7], [4, 8], [4, 9],
        [5, 10], [5, 11], [5, 12], [5, 7], [5, 8], [5, 9],
        [6, 10], [6, 11], [6, 12], [6, 7], [6, 8], [6, 9]
      ]);
      sc.end();
    });
});