Loading...
Searching...
No Matches
writecheck.test.sas
Go to the documentation of this file.
1/**
2 @file
3 @brief testing services/admin/writecheck.sas
4 @details
5 The deploy screen reads checkwrite from this service's response. The path
6 used here cannot exist, which is portable across estates and pins the
7 answer shape without writing anything: PATH_EXISTS is N and IS_FOLDER is N.
8
9 <h4> SAS Macros </h4>
10 @li mpe_execute.sas
11 @li mp_assert.sas
12 @li mp_assertcols.sas
13
14 @sasjslint {"maxLineLength": 80}
15
16**/
17
18%let _program=&appLoc/services/admin/writecheck;
19
20/**
21 * Test 1 - a path that cannot exist is reported as absent, not as an abort
22 */
23data work.fromjs;
24 length path $200;
25 path='/this/path/does/not/exist/dc_writecheck';
26run;
27
28%mpe_execute(&_program,
29 viyacontext=&defaultcontext,
30 inputdatasets=work.fromjs,
31 outlib=web1
32)
33
34data _null_;
35 call symputx('has_chk',ifn(open('web1.checkwrite','i')>0,1,0),'l');
36run;
37%mp_assert(
38 iftrue=(&has_chk=1),
39 desc=The write check returns checkwrite,
40 outds=work.test_results
41)
42
43data _null_;
44 set web1.checkwrite;
45 call symputx('exists',upcase(strip(path_exists)),'l');
46 call symputx('isfolder',upcase(strip(is_folder)),'l');
47run;
48%mp_assert(
49 iftrue=("%superq(exists)"="N"),
50 desc=An absent path is reported as absent,
51 outds=work.test_results
52)
53%mp_assert(
54 iftrue=("%superq(isfolder)"="N"),
55 desc=An absent path is not reported as a folder,
56 outds=work.test_results
57)
58
59/**
60 * Test 2 - an existing folder is reported writeable
61 */
62data work.fromjs;
63 length path $200;
64 path='/tmp';
65run;
66
67%mpe_execute(&_program,
68 viyacontext=&defaultcontext,
69 inputdatasets=work.fromjs,
70 outlib=web2
71)
72
73data _null_;
74 set web2.checkwrite;
75 call symputx('exists2',upcase(strip(path_exists)),'l');
76 call symputx('folder2',upcase(strip(is_folder)),'l');
77 call symputx('write2',upcase(strip(writeable)),'l');
78 call symputx('user2',strip(sysuserid),'l');
79run;
80%mp_assert(
81 iftrue=("%superq(exists2)"="Y" and "%superq(folder2)"="Y"
82 and "%superq(write2)"="Y"),
83 desc=A writeable folder is reported writeable,
84 outds=work.test_results
85)
86%mp_assert(
87 iftrue=(not missing("%superq(user2)")),
88 desc=A writeable folder names the account that can write to it,
89 outds=work.test_results
90)
91
92/*
93 The deploy screen reads these columns by name, and one that stopped being
94 sent would answer blank rather than fail - so the set is pinned here.
95*/
96%mp_assertcols(web2.checkwrite,
97 cols=path path_exists is_folder writeable msg sysuserid,
98 test=ALL
99)
100
101/**
102 * dump results to the log for offline inspection
103 */
104data _null_;
105 set work.test_results;
106 putlog 'TEST_RESULT_LINE: ' test_result ' - ' test_description;
107run;