Skip to content
Snippets Groups Projects
Commit 8cf768d2 authored by S.Listl's avatar S.Listl
Browse files

SqlLib_tests updated

parent 1adf75e1
No related branches found
No related tags found
No related merge requests found
......@@ -646,68 +646,68 @@ var mandatoryErrorTests = new TestSuite([
["and without parameter should error", function(pTester)
{
new SqlBuilder().where().or();
}, SqlBuilder.ERROR_NO_PARAMETER_PROVIDED()],
}, SqlBuilder._ERROR_NO_PARAMETER_PROVIDED()],
["and with null as value should error", function(pTester)
{
new SqlBuilder().where().or("PERSON.FIRSTNAME", null);
}, SqlBuilder.ERROR_VALUE_IS_MANDATORY()],
}, SqlBuilder._ERROR_VALUE_IS_MANDATORY()],
["and with undefined as value should error", function(pTester)
{
new SqlBuilder().where().or("PERSON.FIRSTNAME", undefined);
}, SqlBuilder.ERROR_VALUE_IS_MANDATORY()],
}, SqlBuilder._ERROR_VALUE_IS_MANDATORY()],
["and with a jdito-var containing null should error", function(pTester)
{
vars.set("$global.TestingVarNull", null);
new SqlBuilder().where().or("PERSON.FIRSTNAME", "$global.TestingVarNull");
}, SqlBuilder.ERROR_VALUE_IS_MANDATORY_JDITO_VAR()],
}, SqlBuilder._ERROR_VALUE_IS_MANDATORY_JDITO_VAR()],
["and with an empty sql-builder as subquery should error", function(pTester)
{
new SqlBuilder().where().or("PERSON.FIRSTNAME", new SqlBuilder());
}, SqlBuilder.ERROR_VALUE_IS_MANDATORY()],
}, SqlBuilder._ERROR_VALUE_IS_MANDATORY()],
["and with an empty prepared statement as subquery should error", function(pTester)
{
new SqlBuilder().where().or("PERSON.FIRSTNAME", ["", []]);
}, SqlBuilder.ERROR_VALUE_IS_MANDATORY()],
}, SqlBuilder._ERROR_VALUE_IS_MANDATORY()],
// or
["or without parameter should error", function(pTester)
{
new SqlBuilder().where().or();
}, SqlBuilder.ERROR_NO_PARAMETER_PROVIDED()],
}, SqlBuilder._ERROR_NO_PARAMETER_PROVIDED()],
["or with null as value should error", function(pTester)
{
new SqlBuilder().where().or("PERSON.FIRSTNAME", null);
}, SqlBuilder.ERROR_VALUE_IS_MANDATORY()],
}, SqlBuilder._ERROR_VALUE_IS_MANDATORY()],
["or with undefined as value should error", function(pTester)
{
new SqlBuilder().where().or("PERSON.FIRSTNAME", undefined);
}, SqlBuilder.ERROR_VALUE_IS_MANDATORY()],
}, SqlBuilder._ERROR_VALUE_IS_MANDATORY()],
["or with a jdito-var containing null should error", function(pTester)
{
vars.set("$global.TestingVarNull", null);
new SqlBuilder().where().or("PERSON.FIRSTNAME", "$global.TestingVarNull");
}, SqlBuilder.ERROR_VALUE_IS_MANDATORY_JDITO_VAR()],
}, SqlBuilder._ERROR_VALUE_IS_MANDATORY_JDITO_VAR()],
["or with an empty sql-builder as subquery should error", function(pTester)
{
new SqlBuilder().where().or("PERSON.FIRSTNAME", new SqlBuilder());
}, SqlBuilder.ERROR_VALUE_IS_MANDATORY()],
}, SqlBuilder._ERROR_VALUE_IS_MANDATORY()],
["or with an empty prepared statement as subquery should error", function(pTester)
{
new SqlBuilder().where().or("PERSON.FIRSTNAME", ["", []]);
}, SqlBuilder.ERROR_VALUE_IS_MANDATORY()],
}, SqlBuilder._ERROR_VALUE_IS_MANDATORY()],
]);
var inStatementTests = new TestSuite([
......@@ -766,7 +766,7 @@ var inStatementTests = new TestSuite([
{
new SqlBuilder()
.where("PERSON.LASTNAME", []);
}, SqlBuilder.ERROR_VALUE_IS_MANDATORY()]
}, SqlBuilder._ERROR_VALUE_IS_MANDATORY()]
]);
var testConstantFunctions = new TestSuite([
......@@ -886,7 +886,7 @@ var subqueryAsFieldTests = new TestSuite([
.where("ORGANISATION.ORGANISATIONID = CONTACT.ORGANISATION_ID")
.and("PERSON.FIRSTNAME", "val1") // test if the value is added at the correct place
new SqlBuilder().where(subQuery, "val2", "# = ?");
}, SqlBuilder.ERROR_SUBSELECT_AS_FIELD_NO_FIELD_TYPE()],
}, SqlBuilder._ERROR_SUBSELECT_AS_FIELD_NO_FIELD_TYPE()],
["Test if a Subselect as field should error if it is not a full select.", function(pTester)
{
......@@ -895,7 +895,7 @@ var subqueryAsFieldTests = new TestSuite([
.and("PERSON.FIRSTNAME", "val1") // test if the value is added at the correct place
new SqlBuilder().where(subQuery, "val2", "# = ?", SQLTYPES.VARCHAR);
}, SqlBuilder.ERROR_SUBSELECT_AS_FIELD_NOT_COMPLETE()]
}, SqlBuilder._ERROR_SUBSELECT_AS_FIELD_NOT_COMPLETE()]
]);
var conditionFormatTests = new TestSuite([
......@@ -918,17 +918,17 @@ var conditionFormatTests = new TestSuite([
["pCondition should fail if more than one ? exists", function(pTester)
{
new SqlBuilder().where("PERSON.FIRSTNAME", "val1", "? test ?")
}, SqlBuilder.ERROR_CONDITION_WRONG_FORMAT()],
}, SqlBuilder._ERROR_CONDITION_WRONG_FORMAT()],
["pCondition should fail if more than one # exists", function(pTester)
{
new SqlBuilder().where("PERSON.FIRSTNAME", "val1", "# test #")
}, SqlBuilder.ERROR_CONDITION_WRONG_FORMAT()],
}, SqlBuilder._ERROR_CONDITION_WRONG_FORMAT()],
["pCondition should fail if # and ? are in wrong order", function(pTester)
{
new SqlBuilder().where("PERSON.FIRSTNAME", "val1", "? = #")
}, SqlBuilder.ERROR_CONDITION_WRONG_FORMAT()]
}, SqlBuilder._ERROR_CONDITION_WRONG_FORMAT()]
]);
var subqueryAliasTests = new TestSuite([
......
......@@ -53,6 +53,48 @@ function Tester(pCollectionName)
this.currentTestHadAlreadyAssert = false;
}
/**
* generates a summary of the test results
*
* @return {Obect}
*/
Tester.prototype.getSummary = function ()
{
var summary = {
failures : 0,
successes : 0,
failedTests : [],
getMessage : function ()
{
var message = "-------------------------\n"
+ (this.failures ? "Test failure" : "Test success")
+ "\n-------------------------\nTests performed: " + (this.successes + this.failures)
+ "\nTests successful: " + this.successes
+ "\nTests failed: " + this.failures;
if (this.failedTests.length)
{
message += "\nFailures:";
this.failedTests.forEach(function (testName)
{
message += "\n\t" + testName;
});
}
return message;
}
}
this.testResults.forEach(function ([testName,, successful])
{
if (successful)
summary.successes++;
else
{
summary.failures++;
summary.failedTests.push(testName);
}
});
return summary;
}
/**
* With assert you can test if a variable is the same like an expected value.<br/>
* The test result is added to the Tester<br/>
......@@ -189,4 +231,5 @@ Tester.prototype.printResults = function ()
logging.log(message);
lastTestDescription = pResult[0];
}, this);
logging.log(this.getSummary().getMessage());
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment