Skip to content

Commit

Permalink
LDEV-3122 improve test
Browse files Browse the repository at this point in the history
  • Loading branch information
zspitzer committed Jan 23, 2025
1 parent 4b684ad commit 1c93444
Showing 1 changed file with 28 additions and 30 deletions.
58 changes: 28 additions & 30 deletions test/tickets/LDEV3122.cfc
Original file line number Diff line number Diff line change
@@ -1,60 +1,58 @@
component extends="org.lucee.cfml.test.LuceeTestCase" {
function beforeAll() {
variables.path = "#getDirectoryFromPath(getCurrentTemplatePath())#LDEV3122";
variables.path = getTempDirectory() & "LDEV-3122/";
afterAll();
if(!directoryExists(path)) directoryCreate(path)
}

function run( testResults , testBox ) {

describe( "Testcase for LDEV-3122", function() {
it( title="checking cffile nameconflict=makeunique without file exists", body=function() {
it( title="checking CFFILE nameConflict=makeunique without file exists", body=function() {
fileWrite("#path#\test.txt","LDEV-3122");
var newDir = "#path#\test_#createUniqueID()#";
directoryCreate(newDir)
file action="copy" source="#path#\test.txt" destination=newDir nameconflict="makeunique";

file action="copy" source="#path#\test.txt" destination=newDir nameConflict="makeUnique";
directory action="list" directory=newDir name="list";

expect(list.name).tobe("test.txt");
expect( list.name ).toBe( "test.txt" );
});

it( title="checking cffile nameconflict=makeunique with file exists", body=function() {
it( title="checking CFFILE nameConflict=makeUnique with file exists", body=function() {
var newDir = "#path#\test_#createUniqueID()#";
directoryCreate(newDir)
filewrite("#newDir#\testmakeunique.txt","LDEV-3122");
fileWrite("#newDir#\testMakeUnique.txt","LDEV-3122");

file action="copy" source="#newDir#\testMakeUnique.txt" destination=newDir nameConflict="makeUnique";
directory action="list" directory=newDir name="list" listInfo="name";

file action="copy" source="#newDir#\testmakeunique.txt" destination=newDir nameconflict="makeunique";
directory action="list" directory=newDir name="list" listinfo="name";

if(find("testmakeunique_",serializeJson(list))==0) throw serializeJson(list);

expect(find("testmakeunique_",serializeJson(list))).toBeGT(0);
expect(list.recordcount).toBe("2");
expect( serializeJson( list ) ).toInclude( "testMakeUnique-" );
expect( list.recordcount ).toBe("2");
});
it( title="checking cffile nameconflict=forceunique without file exists", body=function() {

it( title="checking CFFILE nameConflict=forceunique without file exists", body=function() {
var newDir = "#path#\test_#createUniqueID()#";
directoryCreate(newDir)
filewrite("#path#\testforceunique.txt","LDEV-3122");
fileWrite("#path#\testForceUnique.txt","LDEV-3122");

file action="copy" source="#path#\testforceunique.txt" destination=newDir nameconflict="forceunique";
directory action="list" directory=newDir name="list" listinfo="name";
file action="copy" source="#path#\testForceUnique.txt" destination=newDir nameConflict="forceUnique";
directory action="list" directory=newDir name="list" listInfo="name";

expect(find("testforceunique_",serializejson(list))).toBeGT(0);
expect(list.recordcount).toBe("1");
expect( serializeJson( list ) ).toInclude( "testForceUnique-" );
expect( list.recordcount ).toBe("1");
});
it( title="checking cffile nameconflict=forceunique with file exists", body=function() {

it( title="checking CFFILE nameConflict=forceunique with file exists", body=function() {
var newDir = "#path#\test_#createUniqueID()#";
directoryCreate(newDir)
filewrite("#newDir#\testfileforceunique.txt","LDEV-3122");
fileWrite("#newDir#\testFileForceUnique.txt","LDEV-3122");

file action="copy" source="#newDir#\testFileForceUnique.txt" destination=newDir nameConflict="forceUnique";
directory action="list" directory=newDir name="list" listInfo="name";

file action="copy" source="#newDir#\testfileforceunique.txt" destination=newDir nameconflict="forceunique";
directory action="list" directory=newDir name="list" listinfo="name";

expect(find("testfileforceunique_",serializejson(list))).toBeGT(0);
expect(list.recordcount).toBe("2");
expect( serializeJson( list ) ).toInclude( "testFileForceUnique-");
expect( list.recordcount ).toBe("2");
});
});

Expand Down

0 comments on commit 1c93444

Please sign in to comment.