Macros for SAS Application Developers
https://github.com/sasjs/core
ms_getgroups.test.sas
Go to the documentation of this file.
1 /**
2  @file
3  @brief Testing ms_getgroups.sas macro
4 
5  <h4> SAS Macros </h4>
6  @li mf_getuniquename.sas
7  @li ms_adduser2group.sas
8  @li ms_creategroup.sas
9  @li ms_getgroups.sas
10  @li mp_assert.sas
11  @li mp_assertdsobs.sas
12  @li mp_assertscope.sas
13 
14 **/
15 
16 /* create a group */
17 %let group=%substr(%mf_getuniquename(),1,8);
18 %ms_creategroup(&group, desc=The description,mdebug=&sasjs_mdebug,outds=test1)
19 
20 /* get groups */
21 %mp_assertscope(SNAPSHOT)
22 %ms_getgroups(outds=work.test1,mdebug=&sasjs_mdebug)
23 %mp_assertscope(COMPARE
24  ,ignorelist=MCLIB2_JADP1LEN MCLIB2_JADPNUM MCLIB2_JADVLEN
25 )
26 
27 /* check the group was created */
28 %mp_assertdsobs(work.test1,test=ATLEAST 1)
29 
30 %let test2=0;
31 %put &=group;
32 data _null_;
33  set work.test1;
34  putlog (_all_)(=);
35  if upcase(name)="%upcase(&group)" then do;
36  putlog "&group found!";
37  call symputx('test2',1);
38  call symputx('gid',groupid); /* used in next test */
39  end;
40 run;
41 
42 %mp_assert(
43  iftrue=("&test2"="1"),
44  desc=Checking group was created,
45  outds=work.test_results
46 )
47 
48 
49 /* now check if the filter for the groups for a user works */
50 
51 /* add a member */
52 %ms_adduser2group(uid=1,gid=&gid)
53 
54 %ms_getgroups(user=secretuser,outds=work.test3)
55 
56 %let test3=0;
57 data _null_;
58  set work.test3;
59  if groupid=&gid then call symputx('test3',1);
60 run;
61 
62 %mp_assert(
63  iftrue=("&test3"="1"),
64  desc=Checking group list was returned for a user,
65  outds=work.test_results
66 )