Macros for SAS Application Developers
https://github.com/sasjs/core
Loading...
Searching...
No Matches
mp_lockanytable.test.sas
Go to the documentation of this file.
1/**
2 @file
3 @brief Testing mp_lockfilecheck macro
4
5 <h4> SAS Macros </h4>
6 @li mp_lockanytable.sas
7 @li mp_assert.sas
8 @li mp_assertcols.sas
9 @li mp_assertcolvals.sas
10 @li mp_assertscope.sas
11 @li mp_coretable.sas
12
13**/
14
15/* check create table */
16
17%mp_coretable(LOCKTABLE,libds=work.controller)
18
19%mp_assertcols(work.controller,
20 cols=lock_status_cd lock_lib lock_ds lock_user_nm lock_ref lock_pid
21 lock_start_dttm lock_end_dttm,
22 test=ALL,
23 desc=check all control columns exist
24)
25
26/* check lock table */
27options dlcreatedir;
28libname tmp "%sysfunc(pathname(work))/tmp";
29data tmp.sometable;
30 x=1;
31run;
32
33%mp_lockanytable(LOCK,lib=tmp,ds=sometable,ref=This Ref, ctl_ds=work.controller)
34
35data work.checkds1;
36 checkval='SOMETABLE';
37run;
38%mp_assertcolvals(work.controller.lock_ds,
39 checkvals=work.checkds1.checkval,
40 desc=table is captured in lock,
41 test=ANYVAL
42)
43
44data work.checkds2;
45 checkval='LOCKED';
46run;
47%mp_assertcolvals(work.controller.lock_status_cd,
48 checkvals=work.checkds2.checkval,
49 desc=code is captured in lock,
50 test=ANYVAL
51)
52
53
54
55/* check for unsuccessful unlock */
56%mp_lockanytable(UNLOCK,lib=tmp,ds=sometable,ref=bye, ctl_ds=work.controller)
57
58data work.checkds3;
59 checkval='UNLOCKED';
60run;
61%mp_assertcolvals(work.controller.lock_status_cd,
62 checkvals=work.checkds3.checkval,
63 desc=Ref is captured in unlock,
64 test=ANYVAL
65)
66
67/* attempt unlock of a table that was never locked */
68
69%mp_lockanytable(UNLOCK,lib=no,ds=doesnotexist,ref=bye, ctl_ds=work.controller)
70
71%mp_assert(
72 iftrue=(&syscc=0),
73 desc=Ability to unlock a table that was never locked,
74 outds=work.test_results
75)
76
77/* test for macro variable scope leakage */
78%mp_assertscope(SNAPSHOT)
79%mp_lockanytable(LOCK,lib=tmp,ds=testscope,ref=This Ref, ctl_ds=work.controller)
80%mp_assertscope(COMPARE)