Loading...
Searching...
No Matches
exportdb.test.sas
Go to the documentation of this file.
1/**
2 @file
3 @brief testing exportdb service
4
5 <h4> SAS Macros </h4>
6 @li mp_assertdsobs.sas
7 @li mx_execute.sas
8
9**/
10
11
12%let _program=&appLoc/services/admin/exportdb;
13
14/* test 1 - PGSQL flavour */
15data work.params;
16 length name $32 value $1000;
17 name='flavour';value='PGSQL';output;
18 name='schema';value='public';output;
19run;
20%mx_execute(&_program,
21 viyacontext=&defaultcontext,
22 inputparams=work.params,
23 outref=webout,
24 viyaresult=WEBOUT_TXT,
25 mdebug=&sasjs_mdebug
26)
27
28data work.results;
29 infile webout;
30 input;
31 putlog _infile_;
32 if index(upcase(_infile_),'CREATE TABLE') then do;
33 putlog 'test passed';
34 output;
35 stop;
36 end;
37run;
38
39%mp_assertdsobs(work.results,
40 desc=PGSQL flavour DDL file is successfully returned,
41 test=EQUALS 1,
42 outds=work.test_results
43)
44
45/* test 2 - default (SAS) flavour with inserts */
46data work.params;
47 length name $32 value $1000;
48 name='flavour';value='';output;
49 name='schema';value='';output;
50run;
51%mx_execute(&_program,
52 viyacontext=&defaultcontext,
53 inputparams=work.params,
54 outref=web2,
55 viyaresult=WEBOUT_TXT,
56 mdebug=&sasjs_mdebug
57)
58
59data work.results2;
60 infile web2;
61 input;
62 putlog _infile_;
63 if index(upcase(_infile_),'INSERT INTO') then do;
64 putlog 'test passed';
65 output;
66 stop;
67 end;
68run;
69
70%mp_assertdsobs(work.results2,
71 desc=SAS flavour DDL file with inserts is successfully returned,
72 test=EQUALS 1,
73 outds=work.test_results
74)
75
76/* test 3 - TSQL flavour (DDL only, no inserts) */
77data work.params;
78 length name $32 value $1000;
79 name='flavour';value='TSQL';output;
80 name='schema';value='public';output;
81run;
82%mx_execute(&_program,
83 viyacontext=&defaultcontext,
84 inputparams=work.params,
85 outref=web3,
86 viyaresult=WEBOUT_TXT,
87 mdebug=&sasjs_mdebug
88)
89
90data work.results3;
91 infile web3;
92 input;
93 putlog _infile_;
94 if index(upcase(_infile_),'CREATE TABLE') then do;
95 putlog 'test passed';
96 output;
97 stop;
98 end;
99run;
100
101/* scan the whole file for any INSERT - TSQL is DDL only */
102data work.results4;
103 infile web3;
104 input;
105 if index(upcase(_infile_),'INSERT INTO') then do;
106 putlog 'unexpected INSERT found';
107 output;
108 stop;
109 end;
110run;
111
112%mp_assertdsobs(work.results3,
113 desc=TSQL flavour DDL file is successfully returned,
114 test=EQUALS 1,
115 outds=work.test_results
116)
117
118%mp_assertdsobs(work.results4,
119 desc=TSQL flavour export contains no INSERTs (DDL only),
120 test=EQUALS 0,
121 outds=work.test_results
122)