mirror of
https://github.com/sasjs/core.git
synced 2025-12-15 16:14:36 +00:00
feat: mfv_getpathuri macro to get the uri of a file or folder
Also refactoring mv_createfolder.sas
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
**/
|
||||
|
||||
/* location in metadata or SAS Drive for temporary files */
|
||||
%let mcTestAppLoc=/tmp/tests/sasjs/core/%mf_uid();
|
||||
%let mcTestAppLoc=/Public/testresults/sasjs_core/%mf_uid();
|
||||
|
||||
/* set defaults */
|
||||
%mp_init()
|
||||
|
||||
35
tests/viyaonly/mfv_getpathuri.test.sas
Normal file
35
tests/viyaonly/mfv_getpathuri.test.sas
Normal file
@@ -0,0 +1,35 @@
|
||||
/**
|
||||
@file
|
||||
@brief Testing mfv_getpathuri macro function
|
||||
|
||||
<h4> SAS Macros </h4>
|
||||
@li mf_uid.sas
|
||||
@li mfv_getpathuri.sas
|
||||
@li mp_assert.sas
|
||||
@li mv_createfile.sas
|
||||
|
||||
**/
|
||||
|
||||
options mprint sgen;
|
||||
|
||||
%let file=%mf_uid();
|
||||
|
||||
/* create a folder */
|
||||
filename somefile temp;
|
||||
data _null_;
|
||||
file somefile;
|
||||
put 'hello testings';
|
||||
run;
|
||||
%let path=&mcTestAppLoc/temp;
|
||||
%mv_createfile(path=&path, name=&file..txt,inref=somefile)
|
||||
|
||||
|
||||
%mp_assert(
|
||||
iftrue=(%mfv_existfile(&path/&file..txt)=1),
|
||||
desc=Check if created file exists
|
||||
)
|
||||
|
||||
%mp_assert(
|
||||
iftrue=(%length(%mfv_getpathuri(&path/&file..txt))>0),
|
||||
desc=Check that a URI was returned
|
||||
)
|
||||
@@ -21,20 +21,33 @@ data _null_;
|
||||
file somefile;
|
||||
put 'hello testings';
|
||||
run;
|
||||
%mv_createfile(path=&mcTestAppLoc/temp, name=&file..txt,inref=somefile)
|
||||
%mv_createfile(path=&mcTestAppLoc/temp, name=&file..txt,inref=somefile,mdebug=1)
|
||||
|
||||
%mp_assert(
|
||||
iftrue=(%mfv_existfile(&mcTestAppLoc/temp/&file..txt)=1),
|
||||
desc=Check if created file exists
|
||||
)
|
||||
|
||||
%put TEST 2 - html file;
|
||||
filename f2 temp;
|
||||
data _null_;
|
||||
file f2;
|
||||
put '<html><body><p>Hello world</p></body></html>';
|
||||
run;
|
||||
%mv_createfile(path=&mcTestAppLoc/temp, name=test.html,inref=f2,mdebug=1)
|
||||
|
||||
%mp_assert(
|
||||
iftrue=(%mfv_existfile(&mcTestAppLoc/temp/test.html)=1),
|
||||
desc=Check if created file exists
|
||||
)
|
||||
|
||||
%put TEST 2 - dataset upload ;
|
||||
data temp;
|
||||
x=1;
|
||||
run;
|
||||
filename ds "%sysfunc(pathname(work))/temp.sas7bdat";
|
||||
|
||||
%mv_createfile(path=&mcTestAppLoc/temp, name=&file..sas7bdat,inref=ds)
|
||||
%mv_createfile(path=&mcTestAppLoc/temp, name=&file..sas7bdat,inref=ds,mdebug=1)
|
||||
|
||||
%mp_assert(
|
||||
iftrue=(%mfv_existfile(&mcTestAppLoc/temp/&file..sas7bdat)=1),
|
||||
|
||||
@@ -29,4 +29,20 @@ run;
|
||||
%mp_assert(
|
||||
iftrue=(&test=1),
|
||||
desc=Check if temp folder can be successfully created
|
||||
)
|
||||
|
||||
/* create a folder without output dataset as part of the original macro */
|
||||
%mv_createfolder(path=&mcTestAppLoc/temp/&folder/folder2,outds=folders2)
|
||||
|
||||
%let test=0;
|
||||
data _null_;
|
||||
set work.folders2;
|
||||
putlog (_all_)(=);
|
||||
if not missing(self_uri) and not missing(parent_uri)
|
||||
then call symputx('test2',1);
|
||||
run;
|
||||
|
||||
%mp_assert(
|
||||
iftrue=(&test2=1),
|
||||
desc=Check if outds param works
|
||||
)
|
||||
Reference in New Issue
Block a user