Exemplo n.º 1
0
    it("should convert odata request to insert to SQL with numeric and string parameters", function(done){

        options.path = '/' + ACCOUNTID + '/mytable';

        remote.request(options, {
          col1: 22,
          col2: '22'
        })
        .then(function(responseString){

            //console.log(responseString);

            //Response String should be like
            //{"queryType":"insert","schema":"accountid","table":"mytable","adminOp":false,"bucketOp":false,"user":"******","password":"******"}
            //|insert into accountid.mytable(col1,col2) values(22,"22");


            var responseArray = responseString.split("|");
            var ast = JSON.parse(responseArray[0]);
            var query = responseArray[1];

            expect(ast.queryType, 'topic [ast.queryType]').to.equal('insert');
            expect(ast.schema, 'topic [ast.schema]').to.equal(ACCOUNTID);
            expect(ast.table, 'topic [ast.table]').to.equal('mytable');
            expect(ast.adminOp, 'topic [ast.adminOp]').to.equal(false);
            expect(ast.bucketOp, 'topic [ast.bucketOp]').to.equal(false);
            expect(ast.user, 'topic [ast.user]').to.equal(ACCOUNTID);
            expect(ast.password, 'topic [ast.password]').to.equal(PASSWORD);

            expect(query, 'topic [query]').to.equal('insert into accountid.mytable(col1,col2) values(22,"22");');
        })
        .done(done, function (errObject) {console.log('ERROR',  errObject.message);});

    });
Exemplo n.º 2
0
  .then(function (res) {
    console.log(res);

    // METADATA
    options.path = '/' + ACCOUNTID + '/mytable/$metadata';
    options.method = 'GET';
    return remote.request(options, null);
  })
Exemplo n.º 3
0
  .then(function (res) {
    console.log(res);

    // SERVICE DEF
    options.path = '/' + ACCOUNTID;
    options.method = 'GET';
    return remote.request(options, null);
  })
Exemplo n.º 4
0
  .then(function (res) {
    console.log(res);

    // SELECT
    options.path = '/' + ACCOUNTID + '/mytable';
    options.method = 'GET';
    return remote.request(options, null);
  })
Exemplo n.º 5
0
  .then(function (res) {
    console.log(res);

    // SELECT FROM BUCKET
    options.path = '/' + ACCOUNTID + '/b_mybucket';
    options.method = 'GET';
    return remote.request(options, null);
  })
Exemplo n.º 6
0
  .then(function (res) {
    console.log(res);

    // UPDATE
    options.path = '/' + ACCOUNTID + '/mytable';
    options.method = 'PUT';
    return remote.request(options, {
      col2: '33'
    });
  })
Exemplo n.º 7
0
  .then(function (res) {
    console.log(res);

    options.path = '/' + ACCOUNTID + SYS_PATH + '/reset_password';
    options.method = 'POST';
    return remote.request(options, {
      accountId: ACCOUNTID,
      email: EMAIL
    })
  })
Exemplo n.º 8
0
  .then(function (res) {
    console.log(res);

    // DELETE ACCOUNT
    options.path = '/' + ACCOUNTID + SYS_PATH + '/delete_account';
    options.method = 'POST';
    return remote.request(options, {
      email: EMAIL
    });
  })
Exemplo n.º 9
0
  .then(function (res) {
    console.log(res);

    // DROP TABLE
    options.path = '/' + ACCOUNTID + SYS_PATH + '/delete_table';
    options.method = 'POST';
    return remote.request(options, {
      name: "mytable"
    });
  })
Exemplo n.º 10
0
  .then(function (res) {
    console.log(res);

    // DROP BUCKET
    options.path = '/' + ACCOUNTID + SYS_PATH + '/drop_bucket';
    options.method = 'POST';
    return remote.request(options, {
      name: 'b_mybucket'
    });
  })
Exemplo n.º 11
0
  .then(function (res) {
    console.log(res);

    // INCORRECT BUCKET ADMIN OP
    options.path = '/' + ACCOUNTID + SYS_PATH + '/create_bucket2';
    options.method = 'POST';
    return remote.request(options, {
      name: 'b_mybucket'
    });
  })
Exemplo n.º 12
0
  .then(function (res) {
    console.log(res);

    // INSERT INTO
    options.path = '/' + ACCOUNTID + '/mytable';
    options.method = 'POST';
    return remote.request(options, {
      col1: 22,
      col2: '22'
    });
  })
Exemplo n.º 13
0
  .then(function (res) {
    console.log(res);

    // REVOKE BUCKET
    options.path = '/' + ACCOUNTID + SYS_PATH + '/revoke_bucket';
    options.method = 'POST';
    return remote.request(options, {
      name: 'b_mybucket',
      accountId: ACCOUNTID2
    });
  })
Exemplo n.º 14
0
  .then(function (res) {
    console.log(res);

    // ORDER BY
    var params = querystring.stringify({
      $orderby: 'col2'
    });
    options.path = '/schema/table?' + params;
    options.method = 'GET';
    return remote.request(options, null);
  })
Exemplo n.º 15
0
  .then(function (res) {
    console.log(res);

    // GRANT
    options.path = '/' + ACCOUNTID + SYS_PATH + '/grant';
    options.method = 'POST';
    return remote.request(options, {
      name: 'mytable',
      accountId: ACCOUNTID2
    });
  })
Exemplo n.º 16
0
  .then(function (res) {
    console.log(res);

    options.path = '/' + ACCOUNTID + SYS_PATH + '/create_table';
    options.method = 'POST';
    return remote.request(options, {
      tableDef: {
        name: 'mytable',
        columns: ['col1 int', 'col2 varchar(255)']
      }
    });
  })
Exemplo n.º 17
0
  .then(function (res) {
    console.log(res);

    // FILTER, COLS, ORDER BY
    var params = querystring.stringify({
      $select: 'col1,col2',
      $filter: 'Price add 5 gt 10',
      $orderby: 'col2'
    });
    options.path = '/schema/table?' + params;
    options.method = 'GET';
    return remote.request(options, null);
  })
Exemplo n.º 18
0
  .then(function (res) {
    console.log(res);

    // DELETE
    var filter = querystring.stringify({
      $filter: 'col1 eq 22'
    });
    options.path = '/' + ACCOUNTID + '/mytable?' + filter;
    options.method = 'DELETE';
    return remote.request(options, {
      name: 'mytable',
      accountId: ACCOUNTID2
    });
  })
Exemplo n.º 19
0
  .then(function (res) {
    console.log(res);

    // FILTER & ORDER BY
    var params = querystring.stringify({
      $select: 'col1,col2,@odata.etag',
      $filter: 'co1 eq "help"',
      $orderby: 'col2',
      $skip: '10'
    });

    options.path = '/schema/table?' + params;
    options.method = 'GET';

    return remote.request(options, null);
  })
Exemplo n.º 20
0
    it("should convert odata request to update to SQL ", function(done){

        var filter = querystring.stringify({
          $filter: 'col1 eq 22'
        });
        options.path = '/' + ACCOUNTID + '/mytable?' + filter;
        options.method = 'DELETE';
        remote.request(options, {
          name: 'mytable',
          accountId: ACCOUNTID
        })
        .then(function(responseString){

            //console.log(responseString);

            //Response String should be like
            //{"queryType":"delete","schema":"accountid","table":"mytable","sql":" where col1 = 22","adminOp":false,"bucketOp":false,"user":"******","password":"******"}
            //|{"name":"mytable","accountId":"accountid"}


            var responseArray = responseString.split("|");
            var ast = JSON.parse(responseArray[0]);
            var query = JSON.parse(responseArray[1]);

            expect(ast.queryType, 'topic [ast.queryType]').to.equal('delete');
            expect(ast.schema, 'topic [ast.schema]').to.equal(ACCOUNTID);
            expect(ast.table, 'topic [ast.table]').to.equal('mytable');
            expect(ast.adminOp, 'topic [ast.adminOp]').to.equal(false);
            expect(ast.bucketOp, 'topic [ast.bucketOp]').to.equal(false);
            expect(ast.user, 'topic [ast.user]').to.equal(ACCOUNTID);
            expect(ast.password, 'topic [ast.password]').to.equal(PASSWORD);
            expect(ast.sql, 'topic [ast.sql]').to.equal(" where col1 = 22");

            expect(query.name).to.equal('mytable');
            expect(query.accountId).to.equal('accountid');
        })
        .done(done, function (errObject) {console.log('ERROR',  errObject.message);});

    });
Exemplo n.º 21
0
var options = {
  hostname: 'localhost',
  port: 3000,
  headers: {
    user: ACCOUNTID,
    database: ACCOUNTID, // I DON'T THINK THIS IS USED??
    password: PASSWORD
  }
};

console.log('A web server should be running on localhost:3000');

options.path = '/create_account';
options.method = 'POST';
remote.request(options, {
    email: EMAIL
  })
  .then(function (res) {
    console.log(res);

    options.path = '/' + ACCOUNTID + SYS_PATH + '/reset_password';
    options.method = 'POST';
    return remote.request(options, {
      accountId: ACCOUNTID,
      email: EMAIL
    })
  })
  .then(function (res) {
    console.log(res);

    options.path = '/' + ACCOUNTID + SYS_PATH + '/create_table';