Skip to content

Commit

Permalink
split into 3 tests
Browse files Browse the repository at this point in the history
  • Loading branch information
darrell-rg committed Sep 12, 2024
1 parent 6f0f6b4 commit f336eb1
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 27 deletions.
19 changes: 14 additions & 5 deletions test/tickets/LDEV5086.cfc
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
component extends = "org.lucee.cfml.test.LuceeTestCase" labels="orm" {
// run this test with /loader>ant -DtestLabels="orm"
// it will be call test/tickets/LDEV5086/LDEV5086.cfm three times
this.name = "LDEV5086";

public function onRequestStart() {
Expand All @@ -10,23 +12,30 @@ component extends = "org.lucee.cfml.test.LuceeTestCase" labels="orm" {
}

function run( testResults , testBox ) {
describe( "Testcase for LDEV-5086 - bigdecimal", function() {

describe( "Testcase for LDEV-5086 - save bigdecimal via orm", function() {

it(title = "Test that we can save an orm entity with bigdecimal field", body = function( currentSpec ) {
local.result = _InternalRequest(
template : "#uri#/LDEV5086.cfm",
forms : { scene = 1 }
);
expect(trim(result.filecontent)).toBe('success');
expect(trim(result.filecontent)).toBe('success1');
});

it(title = "Test roundtrip of orm entity with bigdecimal field", body = function( currentSpec ) {
it(title = "Test query of orm entity with bigdecimal field", body = function( currentSpec ) {
local.result = _InternalRequest(
template : "#uri#/LDEV5086.cfm",
forms : { scene = 2 }
);
expect(trim(result.filecontent)).toBe('success');
expect(trim(result.filecontent)).toBe('success2');
});

it(title = "Test roundtrip of orm entity with bigdecimal field", body = function( currentSpec ) {
local.result = _InternalRequest(
template : "#uri#/LDEV5086.cfm",
forms : { scene = 3 }
);
expect(trim(result.filecontent)).toBe('success3');
});
});
}
Expand Down
60 changes: 38 additions & 22 deletions test/tickets/LDEV5086/LDEV5086.cfm
Original file line number Diff line number Diff line change
@@ -1,24 +1,19 @@
<cfscript>
try {
// run this test with /loader>>ant -DtestLabels="orm"
// it will be called 3 times by test/tickets/LDEV5086.cfc
param name="form.scene" default="0";
param name="form.scene" default="1";
bigDecimalNumber = 12345.123456
bigDecimalNumber = 12345.123456;
if(form.scene eq 1) {
person = entityNew( "Person", { firstName : "Susi", lastName: "Doe", balance : bigDecimalNumber } ) ;
EntitySave(person);
ormFlush();
writeOutput( "success" );
writeOutput( "success1" );
}
else if(form.scene eq 2) {
//for some reson Susi is getting deleted between tests, so we have to do this again
person = entityNew( "Person", { firstName : "Susi", lastName: "Doe", balance : bigDecimalNumber } ) ;
EntitySave(person);
ormFlush();
minBalance = 10000.023423430;
queryStr = "FROM Person WHERE balance > :minBalance";
results = ORMExecuteQuery(queryStr, {minBalance: minBalance});
Expand All @@ -27,20 +22,41 @@ try {
{
writeOutput( "failure, query did not find Susi" );
}
// check that roundtrip has not changed the balance
for (person in results) {
balance = person.getBalance()
if(balance eq bigDecimalNumber )
{
writeOutput( "success" );
}
else
{
writeOutput( "failure, balance was #balance#" );
else if(arrayLen(results) neq 1)
{
writeOutput( "failure, too many results, expected 1, got #arrayLen(results)# " );
}
else
{
writeOutput( "success2" );
}
}
else if(form.scene eq 3) {
minBalance = 10000.023423430;
queryStr = "FROM Person WHERE balance > :minBalance";
results = ORMExecuteQuery(queryStr, {minBalance: minBalance});
if(arrayLen(results) eq 1)
{
// check that roundtrip has not changed the balance
for (person in results) {
balance = person.getBalance()
if(balance eq bigDecimalNumber )
{
writeOutput( "success3" );
}
else
{
writeOutput( "failure, balance was #balance#, but should be #bigDecimalNumber#" );
}
}
}
else
{
writeOutput( "failure, could not find right number of records" );
}
}
}
Expand Down

0 comments on commit f336eb1

Please sign in to comment.