1
0
mirror of https://github.com/sasjs/core.git synced 2026-01-03 23:50:06 +00:00

fix: tests

This commit is contained in:
munja
2022-01-22 19:47:24 +01:00
parent b69c3b7a78
commit f258d4f2f1
3 changed files with 52 additions and 25 deletions

View File

@@ -299,6 +299,7 @@ proc transpose data=&ds1d(where=(tgtvar_type='C'))
var OLDVAL_CHAR;
run;
data &outdel;
if 0 then set &baselibds;
set &ds2d;
set &ds3d;
drop key_hash;
@@ -328,6 +329,7 @@ proc transpose data=&ds1a(where=(tgtvar_type='C'))
var NEWVAL_CHAR;
run;
data &outadd;
if 0 then set &baselibds;
set &ds2a;
set &ds3a;
drop key_hash;
@@ -358,9 +360,13 @@ proc transpose data=&ds1m(where=(tgtvar_type='C'))
var NEWVAL_CHAR;
run;
data &outmod;
if 0 then set &baselibds;
set &ds2m;
set &ds3m;
run;
proc sort;
by &key;
run;
/**
* Extract matching records from the base table
@@ -422,8 +428,8 @@ run;
* Problems - where record already exists, or base table has columns missing
*/
%let missvars=%mf_wordsinstr1butnotstr2(
Str1=%mf_getvarlist(&outadd),
Str2=%mf_getvarlist(&baselibds)
Str1=%upcase(%mf_getvarlist(&outadd)),
Str2=%upcase(%mf_getvarlist(&baselibds))
);
%if %length(&missvars)>0 %then %do;
/* add them to the err table */
@@ -480,7 +486,7 @@ select distinct tgtvar_nm into: missvars separated by ' '
where move_type='M' and is_diff=1;
%let missvars=%mf_wordsinstr1butnotstr2(
Str1=&missvars,
Str2=%mf_getvarlist(&baselibds)
Str2=%upcase(%mf_getvarlist(&baselibds))
);
%if %length(&missvars)>0 %then %do;
/* add them to the err table */
@@ -524,9 +530,10 @@ select distinct tgtvar_nm into: missvars separated by ' '
if not b;
run;
/* now - we can prepare the final MOD table (which is currently PK only) */
proc sql(undo_policy=none);
proc sql undo_policy=none;
create table &outmod as
select a.* /* includes KEY_HASH from audit ds */
select a.key_hash
,b.*
from &outmod a
inner join &base b
on &keyjoin
@@ -552,7 +559,8 @@ select distinct tgtvar_nm into: missvars separated by ' '
proc datasets lib=work;
delete &prefix:;
run;
%put &sysmacroname exit vars:;
%put _local_;
%end;
%mend mp_stackdiffs;
/** @endcond */`
/** @endcond */

View File

@@ -45,8 +45,12 @@ run;
/**
* Deletions test - where record does not exist
*/
data work.final1;
set work.final;
where move_type='D';
run;
%mp_stackdiffs(work.orig
,work.final
,work.final1
,CUSTOMER YEAR
,mdebug=1
,errds=work.errds1
@@ -69,8 +73,12 @@ data work.orig2;
set sashelp.electric;
if _n_ le 10;
run;
data work.final2;
set work.final;
where move_type='D';
run;
%mp_stackdiffs(work.orig2
,work.final
,work.final2
,CUSTOMER YEAR
,mdebug=1
,errds=work.errds2
@@ -94,8 +102,12 @@ data work.orig3;
set work.orig;
stop;
run;
data work.final3;
set work.final;
where move_type='A';
run;
%mp_stackdiffs(work.orig3
,work.final
,work.final3
,CUSTOMER YEAR
,mdebug=1
,errds=work.errds3
@@ -119,8 +131,12 @@ data work.orig4;
set work.orig;
if _n_>35 then stop;
run;
data work.final4;
set work.final;
where move_type='A';
run;
%mp_stackdiffs(work.orig4
,work.final
,work.final4
,CUSTOMER YEAR
,mdebug=1
,errds=work.errds4
@@ -144,8 +160,12 @@ data work.orig5;
set work.orig;
drop Coal;
run;
data work.final5;
set work.final;
where move_type='A';
run;
%mp_stackdiffs(work.orig5
,work.final
,work.final5
,CUSTOMER YEAR
,mdebug=1
,errds=work.errds5
@@ -167,7 +187,7 @@ run;
*/
data work.final6;
set work.final;
drop Coal;
where tgtvar_nm ne 'COAL' and move_type='A';
run;
%mp_stackdiffs(work.orig
,work.final6
@@ -194,8 +214,12 @@ data work.orig7;
set work.orig;
drop Coal;
run;
data work.final7;
set work.final;
where move_type='M';
run;
%mp_stackdiffs(work.orig7
,work.final
,work.final7
,CUSTOMER YEAR
,mdebug=1
,errds=work.errds7
@@ -220,14 +244,16 @@ run;
test=EQUALS 0
)
/**
* Modifications test - where base table has missing rows
* Modifications (big) test - where base table has missing rows
* Also used as a full integration test (all move_types)
* And a test if the actual values were applied
*/
data work.orig8;
set work.orig;
if _n_ le 16;
run;
%mp_stackdiffs(work.orig8
,work.final7
,work.final
,CUSTOMER YEAR
,mdebug=1
,errds=work.errds8
@@ -243,14 +269,6 @@ run;
desc=Mod8 - 6 records populated (missing rows relevant),
test=EQUALS 6
)
%mp_assertdsobs(work.add8,
desc=add8 - 0 records populated ,
test=EQUALS 0
)
%mp_assertdsobs(work.del8,
desc=del8 - 0 records populated ,
test=EQUALS 0
)
/**
* Modifications test - were diffs actually applied?

View File

@@ -15,7 +15,8 @@
%mp_init()
%macro loglevel();
%if &_debug=2477 %then %do;
%if "&_debug"="2477" or "&_debug"="fields,log,trace" %then %do;
%put debug mode activated;
options mprint;
%end;
%mend loglevel;