Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 27b92a295f
Fetching contributors…

Cannot retrieve contributors at this time

82 lines (60 sloc) 2.46 kb
<cfcomponent output="false" extends="mxunit.framework.TestCase">
<cfscript>
function searchINCRWithNE(){
results = mongo.collection('blog').$ne( 'INCR', javacast('int',1) ).search('TITLE,TS,AUTHOR,PUB_DATE');
assertEquals( 999,results.toArray().size() );
}
function searchINCRWithWhere(){
results = mongo.collection('blog').where( "this.INCR == 1").search('TITLE,TS,AUTHOR,PUB_DATE');
assertEquals( 1,results.toArray().size() );
results = mongo.collection('blog').where( "this.INCR > 0 && this.INCR < 100").search('TITLE,TS,AUTHOR,PUB_DATE');
assertEquals( 99,results.toArray().size() );
}
//1256242383663
function searchTSWithWhere(){
results = mongo.collection('blog').where( "this.TS > 1256242383663").search('TITLE,TS,AUTHOR,PUB_DATE');
assertEquals( 1000,results.toArray().size() );
}
function searchTAGSWithWhere(){
results = mongo.collection('blog').where( "this.TAGS == 'Java'").search('TITLE,TS,AUTHOR,PUB_DATE');
assert( results.toArray().size() > 1 );
}
function searchTitleWithRegEx() {
results = mongo.collection('blog').regex('TITLE','Blog Title No.6[0]{1,1}').search('TITLE,AUTHOR,PUB_DATE');
debug( results.toArray().toString() );
assertEquals( 11,results.toArray().size() );
}
function searchTitleContains() {
results = mongo.collection('blog').exists('TITLE','Blog Title No.60').search('TITLE,AUTHOR,PUB_DATE');
debug( results.toArray().toString() );
assertEquals( 11,results.toArray().size() );
}
function searchTitleStartsWith() {
results = mongo.collection('blog').startsWith('TITLE','Blog Title No.60').search('TITLE,AUTHOR,PUB_DATE');
debug( results.toArray().toString() );
assertEquals( 11,results.toArray().size() );
}
function searchTitleEndsWith() {
results = mongo.collection('blog').endsWith('TITLE','Blog Title No.60').search('TITLE,AUTHOR,PUB_DATE');
debug( results.toArray().toString() );
assertEquals( 11,results.toArray().size() );
}
function testEmptyListToStruct(){
list = '';
s = mongo.listToStruct(list);
debug(s);
assertEquals(0,s.size());
}
function testListToStruct(){
list = 'a,b,c,d,e,f,g';
s = mongo.listToStruct(list);
debug(s);
assertEquals(7,s.size());
}
function setUp(){
mongo = createObject('component','MongoDB');
}
function tearDown(){
}
</cfscript>
</cfcomponent>
Jump to Line
Something went wrong with that request. Please try again.