mirror of
https://github.com/sasjs/core.git
synced 2026-01-14 03:50:06 +00:00
fix: upgrading mv_deleteviyafolder for viya 4 (and adding test)
This commit is contained in:
@@ -110,4 +110,4 @@
|
|||||||
"contextName": "SAS Job Execution compute context"
|
"contextName": "SAS Job Execution compute context"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
52
tests/viyaonly/mv_deleteviyafolder.test.sas
Normal file
52
tests/viyaonly/mv_deleteviyafolder.test.sas
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
/**
|
||||||
|
@file
|
||||||
|
@brief Testing mv_deleteviyafolder macro function
|
||||||
|
|
||||||
|
<h4> SAS Macros </h4>
|
||||||
|
@li mf_uid.sas
|
||||||
|
@li mfv_existfolder.sas
|
||||||
|
@li mp_assert.sas
|
||||||
|
@li mp_assertscope.sas
|
||||||
|
@li mv_createfolder.sas
|
||||||
|
@li mv_deleteviyafolder.sas
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
options mprint sgen;
|
||||||
|
|
||||||
|
%let folder=%mf_uid();
|
||||||
|
%let tgtfolder=&mcTestAppLoc/temp/&folder;
|
||||||
|
|
||||||
|
/* create a folder */
|
||||||
|
%mv_createfolder(path=&tgtfolder)
|
||||||
|
|
||||||
|
|
||||||
|
%mp_assert(
|
||||||
|
iftrue=(%mfv_existfolder(&tgtfolder)=1),
|
||||||
|
desc=Check if created folder exists
|
||||||
|
)
|
||||||
|
|
||||||
|
%mp_assertscope(SNAPSHOT)
|
||||||
|
%mv_deleteviyafolder(path=&tgtfolder)
|
||||||
|
/* ignore proc json vars */
|
||||||
|
%mp_assertscope(COMPARE
|
||||||
|
,ignorelist=MCLIB0_JADP1LEN MCLIB0_JADP2LEN MCLIB0_JADVLEN MCLIB2_JADP1LEN
|
||||||
|
MCLIB2_JADVLEN
|
||||||
|
)
|
||||||
|
|
||||||
|
%mp_assert(
|
||||||
|
iftrue=(%mfv_existfolder(&tgtfolder)=0),
|
||||||
|
desc=Check if deleted folder is gone
|
||||||
|
)
|
||||||
|
|
||||||
|
/* delete folder with content */
|
||||||
|
%mv_createfolder(path=&tgtfolder/content/and/stuff)
|
||||||
|
%mp_assert(
|
||||||
|
iftrue=(%mfv_existfolder(&tgtfolder/content/and/stuff)=1),
|
||||||
|
desc=Check if folder with content exists
|
||||||
|
)
|
||||||
|
%mv_deleteviyafolder(path=&tgtfolder)
|
||||||
|
%mp_assert(
|
||||||
|
iftrue=(%mfv_existfolder(&tgtfolder)=0),
|
||||||
|
desc=Check if deleted folder with subfolders is gone
|
||||||
|
)
|
||||||
@@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
<h4> SAS Macros </h4>
|
<h4> SAS Macros </h4>
|
||||||
@li mp_assert.sas
|
@li mp_assert.sas
|
||||||
|
@li mp_assertscope.sas
|
||||||
@li mv_createjob.sas
|
@li mv_createjob.sas
|
||||||
@li mv_jobexecute.sas
|
@li mv_jobexecute.sas
|
||||||
@li mv_jobwaitfor.sas
|
@li mv_jobwaitfor.sas
|
||||||
|
|||||||
@@ -8,10 +8,16 @@
|
|||||||
%mv_deleteviyafolder(path=/Public/test)
|
%mv_deleteviyafolder(path=/Public/test)
|
||||||
|
|
||||||
|
|
||||||
@param path= The full path of the folder to be deleted
|
@param [in] path= The full path of the folder to be deleted
|
||||||
@param access_token_var= The global macro variable to contain the access token
|
@param [in] access_token_var= (ACCESS_TOKEN) The global macro variable to
|
||||||
@param grant_type= valid values are "password" or "authorization_code" (unquoted).
|
contain the access token
|
||||||
The default is authorization_code.
|
@param [in] grant_type= (sas_services) Valid values are:
|
||||||
|
@li password
|
||||||
|
@li authorization_code
|
||||||
|
@li detect - will check if access_token exists, if not will use sas_services
|
||||||
|
if a SASStudioV session else authorization_code. Default option.
|
||||||
|
@li sas_services - will use oauth_bearer=sas_services.
|
||||||
|
@param [in] mdebug= (0) Set to 1 to enable DEBUG messages
|
||||||
|
|
||||||
|
|
||||||
@version VIYA V.03.04
|
@version VIYA V.03.04
|
||||||
@@ -29,6 +35,7 @@
|
|||||||
%macro mv_deleteviyafolder(path=
|
%macro mv_deleteviyafolder(path=
|
||||||
,access_token_var=ACCESS_TOKEN
|
,access_token_var=ACCESS_TOKEN
|
||||||
,grant_type=sas_services
|
,grant_type=sas_services
|
||||||
|
,mdebug=0
|
||||||
);
|
);
|
||||||
%local oauth_bearer;
|
%local oauth_bearer;
|
||||||
%if &grant_type=detect %then %do;
|
%if &grant_type=detect %then %do;
|
||||||
@@ -105,14 +112,17 @@ run;
|
|||||||
%let libref1a=%mf_getuniquelibref();
|
%let libref1a=%mf_getuniquelibref();
|
||||||
libname &libref1a JSON fileref=&fname1a;
|
libname &libref1a JSON fileref=&fname1a;
|
||||||
|
|
||||||
data _null_;
|
%if %mf_existds(&libref1a..items_links) %then %do;
|
||||||
set &libref1a..items_links;
|
data _null_;
|
||||||
if href=:'/folders/folders' then return;
|
set &libref1a..items_links;
|
||||||
if rel='deleteResource' then
|
if href=:'/folders/folders' then return;
|
||||||
call execute('proc http method="DELETE" url='!!quote("&base_uri"!!trim(href))
|
if rel='deleteResource' then
|
||||||
!!'; headers "Authorization"="Bearer &&&access_token_var" '
|
call execute('proc http method="DELETE" url='
|
||||||
!!' "Accept"="*/*";run; /**/');
|
!!quote("&base_uri"!!trim(href))
|
||||||
run;
|
!!'; headers "Authorization"="Bearer &&&access_token_var" '
|
||||||
|
!!' "Accept"="*/*";run; /**/');
|
||||||
|
run;
|
||||||
|
%end;
|
||||||
|
|
||||||
%put &sysmacroname: perform the delete operation ;
|
%put &sysmacroname: perform the delete operation ;
|
||||||
%local fname2;
|
%local fname2;
|
||||||
@@ -133,9 +143,11 @@ run;
|
|||||||
%end;
|
%end;
|
||||||
%else %put &sysmacroname: &path successfully deleted;
|
%else %put &sysmacroname: &path successfully deleted;
|
||||||
|
|
||||||
/* clear refs */
|
%if &mdebug=0 %then %do;
|
||||||
filename &fname1 clear;
|
/* clear refs */
|
||||||
filename &fname2 clear;
|
filename &fname1 clear;
|
||||||
libname &libref1 clear;
|
filename &fname2 clear;
|
||||||
|
libname &libref1 clear;
|
||||||
|
%end;
|
||||||
|
|
||||||
%mend mv_deleteviyafolder;
|
%mend mv_deleteviyafolder;
|
||||||
|
|||||||
@@ -172,6 +172,12 @@ data _null_;
|
|||||||
else if sourcechar='n' then put '0A'x;
|
else if sourcechar='n' then put '0A'x;
|
||||||
else if sourcechar='r' then put '0D'x;
|
else if sourcechar='r' then put '0D'x;
|
||||||
else if sourcechar='t' then put '09'x;
|
else if sourcechar='t' then put '09'x;
|
||||||
|
else if sourcechar='u' then do;
|
||||||
|
length uni $4;
|
||||||
|
input uni $ 4. @@;
|
||||||
|
sourcechar=unicode('\u'!!uni);
|
||||||
|
put sourcechar char1.;
|
||||||
|
end;
|
||||||
else do;
|
else do;
|
||||||
call symputx('errmsg',"Uncaught escape char: "!!sourcechar,'l');
|
call symputx('errmsg',"Uncaught escape char: "!!sourcechar,'l');
|
||||||
call symputx('syscc',99);
|
call symputx('syscc',99);
|
||||||
|
|||||||
Reference in New Issue
Block a user