Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
basic
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
xrm
basic
Commits
8cf768d2
Commit
8cf768d2
authored
4 years ago
by
S.Listl
Browse files
Options
Downloads
Patches
Plain Diff
SqlLib_tests updated
parent
1adf75e1
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
process/SqlLib_tests/process.js
+18
-18
18 additions, 18 deletions
process/SqlLib_tests/process.js
process/UnitTest_lib/process.js
+43
-0
43 additions, 0 deletions
process/UnitTest_lib/process.js
with
61 additions
and
18 deletions
process/SqlLib_tests/process.js
+
18
−
18
View file @
8cf768d2
...
...
@@ -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
([
...
...
This diff is collapsed.
Click to expand it.
process/UnitTest_lib/process.js
+
43
−
0
View file @
8cf768d2
...
...
@@ -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
-------------------------
\n
Tests performed:
"
+
(
this
.
successes
+
this
.
failures
)
+
"
\n
Tests successful:
"
+
this
.
successes
+
"
\n
Tests failed:
"
+
this
.
failures
;
if
(
this
.
failedTests
.
length
)
{
message
+=
"
\n
Failures:
"
;
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
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment