From 5f8d4024cc679bfdf96fa056c2039c0e16296d6b Mon Sep 17 00:00:00 2001 From: Zac Spitzer Date: Sat, 20 Jul 2024 07:18:05 +0200 Subject: [PATCH] LDEV-5034 test case forFileSetAccessMode https://luceeserver.atlassian.net/browse/LDEV-5034 --- test/functions/FileSetAccessMode.cfc | 64 ++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 test/functions/FileSetAccessMode.cfc diff --git a/test/functions/FileSetAccessMode.cfc b/test/functions/FileSetAccessMode.cfc new file mode 100644 index 00000000000..421172395b9 --- /dev/null +++ b/test/functions/FileSetAccessMode.cfc @@ -0,0 +1,64 @@ +component extends="org.lucee.cfml.test.LuceeTestCase" { + + function run( testResults, testBox ){ + describe( "fileSetAccessMode", function(){ + + it( title="test access modes", skip=isNotUnix(), body=function(){ + + var dir = getTempDirectory() & "fileSetAccessMode/"; + if ( !directoryExists( dir ) ){ + directoryCreate( dir ); + }; + + var tests = []; + + arrayAppend( tests, _dir( dir, "755", "755" ) ); + arrayAppend( tests, _dir( dir, "644", "644" ) ); + + arrayAppend( tests, _file( dir, "755/644.txt", "644" ) ); + arrayAppend( tests, _file( dir, "755/743.txt", "743" ) ); + arrayAppend( tests, _file( dir, "755/043.txt", "043" ) ); + + arrayAppend( tests, _file( dir, "644/400.txt", "400" ) ); + + var files = directoryList( dir, true, "query"); + var st = QueryToStruct( files, "name" ); + + loop array=tests index="local.test"{ + systemOutput( test, true ); + } + + loop array=st index="local.item"{ + systemOutput( item, true ); + } + + }); + + } ); + } + + private function _dir(parent, name, mode){ + var dir = directoryCreate( name & mode ); + fileSetAccessMode( dir, mode ); + return { + name: dir, + mode: mode, + type: "dir" + }; + } + + private function _file(parent, name, mode){ + var file = fileWrite( parent & name, "" ); + fileSetAccessMode( file, mode ); + return { + name: file, + mode: mode, + type: "file" + }; + } + + private function isNotUnix(){ + return (server.os.name != "windows"); + } + +}