Skip to content

Commit

Permalink
LDEV-224 improve test
Browse files Browse the repository at this point in the history
  • Loading branch information
zspitzer committed Dec 12, 2024
1 parent b5cb25a commit 3d6c56d
Showing 1 changed file with 37 additions and 10 deletions.
47 changes: 37 additions & 10 deletions test/tickets/LDEV0224_1.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ component extends="org.lucee.cfml.test.LuceeTestCase" labels="qoq"{
}

function run( testResults , testBox ) {
describe( title='selecting 2 rows from QoQ' , body=function() {
//describe( title='selecting 2 rows from QoQ' , body=function() {
describe( title='is possible using a hard coded list' , body=function() {
it( title='of numerics' , body=function( currentSpec ) {
var actual = QueryExecute(
Expand All @@ -28,6 +28,7 @@ component extends="org.lucee.cfml.test.LuceeTestCase" labels="qoq"{
"
);
expect( actual.RecordCount ).toBe( ListLen( interestingNumbersAsAList , ',' ) );
expect( queryColumnData( actual, "id" ).toList() ).toBe( interestingNumbersAsAList );
});

it( title='of strings' , body=function( currentSpec ) {
Expand All @@ -44,11 +45,12 @@ component extends="org.lucee.cfml.test.LuceeTestCase" labels="qoq"{
"
);
expect( actual.RecordCount ).toBe( ListLen( interestingStringsAsAQuotedList , ',' ) );
expect( queryColumnData( actual, "value" ).toList() ).toBe( interestingStringsAsAList );
});
});

describe( title='using param list=true' , body=function() {
describe( title='with new Query()' , body=function() {
//describe( title='using param list=true' , body=function() {
describe( title='using param list=true, with new Query()' , body=function() {
beforeEach( function( currentSpec ) {
q = new Query(
dbtype = 'query',
Expand All @@ -64,9 +66,11 @@ component extends="org.lucee.cfml.test.LuceeTestCase" labels="qoq"{
value
FROM queryWithDataIn
WHERE id IN ( :needle )
ORDER BY ID
" ).getResult();

expect( actual.RecordCount ).toBe( ListLen( interestingNumbersAsAList , ',' ) );
expect( queryColumnData( actual, "id" ).toList() ).toBe( interestingNumbersAsAList );
});

it( title='when using numeric params and a custom separator' , body=function( currentSpec ) {
Expand All @@ -77,9 +81,11 @@ component extends="org.lucee.cfml.test.LuceeTestCase" labels="qoq"{
value
FROM queryWithDataIn
WHERE id IN ( :needle )
ORDER BY ID
" ).getResult();

expect( actual.RecordCount ).toBe( ListLen( interestingNumbersAsAList , ',' ) );
expect( queryColumnData( actual, "id" ).toList() ).toBe( interestingNumbersAsAList );
});

it( title='when using string params' , body=function( currentSpec ) {
Expand All @@ -90,12 +96,14 @@ component extends="org.lucee.cfml.test.LuceeTestCase" labels="qoq"{
value
FROM queryWithDataIn
WHERE value IN ( :needle )
ORDER BY ID
" ).getResult();
expect( actual.RecordCount ).toBe( ListLen( interestingStringsAsAList , ',' ) );
expect( queryColumnData( actual, "value" ).toList() ).toBe( interestingStringsAsAList );
});
});

describe( title='with query{} ( cfquery )' , body=function() {
describe( title='using param list=true, with query{} ( cfquery )' , body=function() {
it( title='when using numeric params' , body=function( currentSpec ) {
query
name = 'actual'
Expand All @@ -111,9 +119,12 @@ component extends="org.lucee.cfml.test.LuceeTestCase" labels="qoq"{
value = interestingNumbersAsAList
sqltype = 'integer'
list = true;
WriteOutput( " )" );
WriteOutput( " )
ORDER BY ID
" );
}
expect( actual.RecordCount ).toBe( ListLen( interestingNumbersAsAList , ',' ) );
expect( queryColumnData( actual, "id" ).toList() ).toBe( interestingNumbersAsAList );
});

it( title='when using numeric params and a custom separator' , body=function( currentSpec ) {
Expand All @@ -132,9 +143,12 @@ component extends="org.lucee.cfml.test.LuceeTestCase" labels="qoq"{
sqltype = 'integer'
list = true
separator = '|';
WriteOutput( " )" );
WriteOutput( " )
ORDER BY ID
" );
}
expect( actual.RecordCount ).toBe( ListLen( interestingNumbersAsAList , ',' ) );
expect( queryColumnData( actual, "id" ).toList() ).toBe( interestingNumbersAsAList );
});

it( title='when using string params' , body=function( currentSpec ) {
Expand All @@ -152,14 +166,17 @@ component extends="org.lucee.cfml.test.LuceeTestCase" labels="qoq"{
value = interestingStringsAsAList
sqltype = 'varchar'
list = true;
WriteOutput( " )" );
WriteOutput( " )
ORDER BY ID
" );
}
expect( actual.RecordCount ).toBe( ListLen( interestingStringsAsAList , ',' ) );
expect( queryColumnData( actual, "value" ).toList() ).toBe( interestingStringsAsAList );
});

});

describe( title='with QueryExecute' , body=function() {
describe( title='using param list=true, with QueryExecute' , body=function() {
it( title='when using an array of numeric params' , body=function( currentSpec ) {
var actual = QueryExecute(
params = [
Expand All @@ -174,9 +191,11 @@ component extends="org.lucee.cfml.test.LuceeTestCase" labels="qoq"{
value
FROM queryWithDataIn
WHERE id IN ( :needle )
ORDER BY ID
"
);
expect( actual.RecordCount ).toBe( ListLen( interestingNumbersAsAList , ',' ) );
expect( queryColumnData( actual, "id" ).toList() ).toBe( interestingNumbersAsAList );
});

it( title='when using a struct of numeric params' , body=function( currentSpec ) {
Expand All @@ -193,9 +212,11 @@ component extends="org.lucee.cfml.test.LuceeTestCase" labels="qoq"{
value
FROM queryWithDataIn
WHERE id IN ( :needle )
ORDER BY ID
"
);
expect( actual.RecordCount ).toBe( ListLen( interestingNumbersAsAList , ',' ) );
expect( queryColumnData( actual, "id" ).toList() ).toBe( interestingNumbersAsAList );
});

it( title='when using an array of string params' , body=function( currentSpec ) {
Expand All @@ -212,9 +233,11 @@ component extends="org.lucee.cfml.test.LuceeTestCase" labels="qoq"{
value
FROM queryWithDataIn
WHERE value IN ( :needle )
ORDER BY ID
"
);
expect( actual.RecordCount ).toBe( ListLen( interestingStringsAsAList , ',' ) );
expect( queryColumnData( actual, "value" ).toList() ).toBe( interestingStringsAsAList );
});

it( title='when using a struct of string params' , body=function( currentSpec ) {
Expand All @@ -231,9 +254,11 @@ component extends="org.lucee.cfml.test.LuceeTestCase" labels="qoq"{
value
FROM queryWithDataIn
WHERE value IN ( :needle )
ORDER BY ID
"
);
expect( actual.RecordCount ).toBe( ListLen( interestingStringsAsAList , ',' ) );
expect( queryColumnData( actual, "value" ).toList() ).toBe( interestingStringsAsAList );
});

it( title='when using numeric params and a custom separator' , body=function( currentSpec ) {
Expand All @@ -250,12 +275,14 @@ component extends="org.lucee.cfml.test.LuceeTestCase" labels="qoq"{
value
FROM queryWithDataIn
WHERE id IN ( :needle )
ORDER BY ID
"
);
expect( actual.RecordCount ).toBe( ListLen( interestingNumbersAsAList , ',' ) );
expect( queryColumnData( actual, "id" ).toList() ).toBe( interestingNumbersAsAList );
});
});
});
});
// });
//});
}
}

0 comments on commit 3d6c56d

Please sign in to comment.