Skip to content

Commit

Permalink
improved coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
Pamblam committed Feb 8, 2018
1 parent 6dd2fb8 commit a90a757
Show file tree
Hide file tree
Showing 8 changed files with 65 additions and 16 deletions.
2 changes: 1 addition & 1 deletion README.md
@@ -1,6 +1,6 @@
[![jSQL Logo](http://i.imgur.com/VQlJKOc.png)](http://pamblam.github.io/jSQL/)

jSQL (Official) - Version 3.2.9 - *Now available without a prescription!*
jSQL (Official) - Version 3.3.5 - *Now available without a prescription!*

[![npm version](https://badge.fury.io/js/jsql-official.svg)](https://badge.fury.io/js/jsql-official) [![Build Status](https://travis-ci.org/Pamblam/jSQL.svg?branch=master)](https://travis-ci.org/Pamblam/jSQL) [![Inline docs](http://inch-ci.org/github/Pamblam/jSQL.svg?branch=master)](https://github.com/Pamblam/jSQL/wiki) [![Coverage Status](https://coveralls.io/repos/github/Pamblam/jSQL/badge.svg?branch=master)](https://coveralls.io/github/Pamblam/jSQL?branch=master)

Expand Down
9 changes: 3 additions & 6 deletions jSQL.js
@@ -1,5 +1,5 @@
/**
* jsql-official - v3.2.9
* jsql-official - v3.3.5
* A persistent SQL database.
* @author Rob Parham
* @website http://pamblam.github.io/jSQL/
Expand All @@ -16,10 +16,8 @@ function jSQL_Error(error_no) {
this.stack = undefined;
var e = new Error();
if(e.stack) this.stack = e.stack;
if(jSQL_Error.message_codes[error_no]) this.message = jSQL_Error.message_codes[error_no];
else this.message = "Unknown error.";
this.message = jSQL_Error.message_codes[error_no];
this.toString = function () {
if(undefined === this.error) return "jSQL Error - "+this.message;
return "jSQL Error #"+this.error+" - "+this.message;
};
}
Expand Down Expand Up @@ -491,7 +489,6 @@ jSQLTable.prototype.initAI = function(auto_increment){
}
};

/* istanbul ignore next */
jSQLTable.prototype.renameColumn = function(oldname, newname){
if(undefined === oldname || "string" !== typeof newname) return _throw(new jSQL_Error("0012"));
if(this.columns.indexOf(oldname) < 0) return _throw(new jSQL_Error("0013"));
Expand Down Expand Up @@ -2816,7 +2813,7 @@ function jsql_import(dump){
}

return {
version: "3.2.9",
version: "3.3.5",
tables: {},
query: jSQLParseQuery,
createTable: createTable,
Expand Down
4 changes: 2 additions & 2 deletions jSQL.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "jsql-official",
"version": "3.3.0",
"version": "3.3.5",
"description": "A persistent SQL database.",
"main": "jSQL.min.js",
"directories": {
Expand Down
4 changes: 1 addition & 3 deletions src/error_handling/jSQL_Error.js
Expand Up @@ -4,10 +4,8 @@ function jSQL_Error(error_no) {
this.stack = undefined;
var e = new Error();
if(e.stack) this.stack = e.stack;
if(jSQL_Error.message_codes[error_no]) this.message = jSQL_Error.message_codes[error_no];
else this.message = "Unknown error.";
this.message = jSQL_Error.message_codes[error_no];
this.toString = function () {
if(undefined === this.error) return "jSQL Error - "+this.message;
return "jSQL Error #"+this.error+" - "+this.message;
};
}
Expand Down
1 change: 0 additions & 1 deletion src/table/jSQLTable.js
Expand Up @@ -107,7 +107,6 @@ jSQLTable.prototype.initAI = function(auto_increment){
}
};

/* istanbul ignore next */
jSQLTable.prototype.renameColumn = function(oldname, newname){
if(undefined === oldname || "string" !== typeof newname) return _throw(new jSQL_Error("0012"));
if(this.columns.indexOf(oldname) < 0) return _throw(new jSQL_Error("0013"));
Expand Down
47 changes: 45 additions & 2 deletions test/test2.js
Expand Up @@ -34,12 +34,55 @@ jSQL.load(function () {
});

it('mixing arrays and objects', function(){
jSQL.createTable("ceTable", ['u0', 'b', 'c', 'd', 'e', 'f', 'g']).execute([
jSQL.createTable("cjjTable", ['u0', 'b', 'c', 'd', 'e', 'f', 'g']).execute([
[12, 34, 56, 78],
[23, 45, 67, 89, 78, 78],
[7], {"a": 1, "b": 2, "g": 3}
]);
expect((jSQL.tables.ceTable.data.length === 4 && jSQL.tables.ceTable.columns.length === 7)).to.be.true;

expect((jSQL.tables.cjjTable.data.length === 4 && jSQL.tables.cjjTable.columns.length === 7)).to.be.true;
});

it('rename columns', function(){
jSQL.query("create table ceTable (u0, b, c, d, e, f, g, primary key(b), unique key(c))").execute();
jSQL.insertInto("ceTable").values({u0:2, b:3, c:34}).execute();
try{
jSQL.tables.ceTable.renameColumn('u0', {});
}catch(e){}
try{
jSQL.tables.ceTable.renameColumn('b', 'adfa');
}catch(e){}
try{
jSQL.tables.ceTable.renameColumn('b', 'c');
}catch(e){}
try{
jSQL.deleteFrom("asdf").execute();
}catch(e){}
try{
jSQL.deleteFrom("ceTable").execute();
}catch(e){}

jSQL.tables.ceTable.renameColumn('u0', 'ufff');
expect(jSQL.tables.ceTable.columns[0] == 'ufff').to.be.true;

jSQL.query("create table abc (a, b, c, primary key (a, b))").execute();
jSQL.query("create table bcd (a int auto_increment, b, c, primary key (a))").execute();
jSQL.query("insert into bcd values (1, 'd', 'e')").execute();
jSQL.query("insert into bcd values (2, 'd', 'j')").execute();
jSQL.query("insert into bcd (b,c) values ('d', 'f')").execute();
jSQL.query("update bcd set a = ? where c = ?").execute([5, 'f']);
jSQL.query("update bcd set a = ? where c = ?").execute([null, 'f']);

jSQL.query("create table cde (a, b, c, unique key (a, b))").execute();
jSQL.query("insert into abc values ('a', 'c', 'c')").execute();
jSQL.query("insert into abc values ('c', 'd', 'e')").execute();
jSQL.query("insert into cde values ('a', 'c', 'c')").execute();
jSQL.query("insert into cde values ('c', 'd', 'e')").execute();
jSQL.query("update abc set a = ? where c = ?").execute(['a', 'e']);
jSQL.query("update cde set a = ? where c = ?").execute(['a', 'e']);

try{jSQL.query("update asdfasd set a = ? where c = ?").execute(['a', 'e']);}catch(e){}
try{jSQL.update("asdfasd")}catch(e){}
});

});
Expand Down
12 changes: 12 additions & 0 deletions test/test4.js
Expand Up @@ -108,5 +108,17 @@ jSQL.load(function () {
expect(e_).to.be.true;
});

it('Testing Parser Error', function(){
var e_ = false;
try{
jSQL.query("insert into farts suckbudda suckbudda suckbudda suckbudda suckbudda suckbudda suckbudda suckbudda suckbudda suckbudda suckbudda suckbudda").execute();
q.execute();
}catch(e){
console.log(e.toString());
e_ = true;
}
expect(e_).to.be.true;
});

});
});

0 comments on commit a90a757

Please sign in to comment.