mirror of
https://github.com/sasjs/core.git
synced 2026-01-15 12:30:06 +00:00
fix: tests
This commit is contained in:
@@ -299,6 +299,7 @@ proc transpose data=&ds1d(where=(tgtvar_type='C'))
|
|||||||
var OLDVAL_CHAR;
|
var OLDVAL_CHAR;
|
||||||
run;
|
run;
|
||||||
data &outdel;
|
data &outdel;
|
||||||
|
if 0 then set &baselibds;
|
||||||
set &ds2d;
|
set &ds2d;
|
||||||
set &ds3d;
|
set &ds3d;
|
||||||
drop key_hash;
|
drop key_hash;
|
||||||
@@ -328,6 +329,7 @@ proc transpose data=&ds1a(where=(tgtvar_type='C'))
|
|||||||
var NEWVAL_CHAR;
|
var NEWVAL_CHAR;
|
||||||
run;
|
run;
|
||||||
data &outadd;
|
data &outadd;
|
||||||
|
if 0 then set &baselibds;
|
||||||
set &ds2a;
|
set &ds2a;
|
||||||
set &ds3a;
|
set &ds3a;
|
||||||
drop key_hash;
|
drop key_hash;
|
||||||
@@ -358,9 +360,13 @@ proc transpose data=&ds1m(where=(tgtvar_type='C'))
|
|||||||
var NEWVAL_CHAR;
|
var NEWVAL_CHAR;
|
||||||
run;
|
run;
|
||||||
data &outmod;
|
data &outmod;
|
||||||
|
if 0 then set &baselibds;
|
||||||
set &ds2m;
|
set &ds2m;
|
||||||
set &ds3m;
|
set &ds3m;
|
||||||
run;
|
run;
|
||||||
|
proc sort;
|
||||||
|
by &key;
|
||||||
|
run;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extract matching records from the base table
|
* Extract matching records from the base table
|
||||||
@@ -422,8 +428,8 @@ run;
|
|||||||
* Problems - where record already exists, or base table has columns missing
|
* Problems - where record already exists, or base table has columns missing
|
||||||
*/
|
*/
|
||||||
%let missvars=%mf_wordsinstr1butnotstr2(
|
%let missvars=%mf_wordsinstr1butnotstr2(
|
||||||
Str1=%mf_getvarlist(&outadd),
|
Str1=%upcase(%mf_getvarlist(&outadd)),
|
||||||
Str2=%mf_getvarlist(&baselibds)
|
Str2=%upcase(%mf_getvarlist(&baselibds))
|
||||||
);
|
);
|
||||||
%if %length(&missvars)>0 %then %do;
|
%if %length(&missvars)>0 %then %do;
|
||||||
/* add them to the err table */
|
/* 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;
|
where move_type='M' and is_diff=1;
|
||||||
%let missvars=%mf_wordsinstr1butnotstr2(
|
%let missvars=%mf_wordsinstr1butnotstr2(
|
||||||
Str1=&missvars,
|
Str1=&missvars,
|
||||||
Str2=%mf_getvarlist(&baselibds)
|
Str2=%upcase(%mf_getvarlist(&baselibds))
|
||||||
);
|
);
|
||||||
%if %length(&missvars)>0 %then %do;
|
%if %length(&missvars)>0 %then %do;
|
||||||
/* add them to the err table */
|
/* add them to the err table */
|
||||||
@@ -524,9 +530,10 @@ select distinct tgtvar_nm into: missvars separated by ' '
|
|||||||
if not b;
|
if not b;
|
||||||
run;
|
run;
|
||||||
/* now - we can prepare the final MOD table (which is currently PK only) */
|
/* 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
|
create table &outmod as
|
||||||
select a.* /* includes KEY_HASH from audit ds */
|
select a.key_hash
|
||||||
|
,b.*
|
||||||
from &outmod a
|
from &outmod a
|
||||||
inner join &base b
|
inner join &base b
|
||||||
on &keyjoin
|
on &keyjoin
|
||||||
@@ -552,7 +559,8 @@ select distinct tgtvar_nm into: missvars separated by ' '
|
|||||||
proc datasets lib=work;
|
proc datasets lib=work;
|
||||||
delete &prefix:;
|
delete &prefix:;
|
||||||
run;
|
run;
|
||||||
|
%put &sysmacroname exit vars:;
|
||||||
|
%put _local_;
|
||||||
%end;
|
%end;
|
||||||
|
|
||||||
%mend mp_stackdiffs;
|
%mend mp_stackdiffs;
|
||||||
/** @endcond */`
|
/** @endcond */
|
||||||
@@ -45,8 +45,12 @@ run;
|
|||||||
/**
|
/**
|
||||||
* Deletions test - where record does not exist
|
* Deletions test - where record does not exist
|
||||||
*/
|
*/
|
||||||
|
data work.final1;
|
||||||
|
set work.final;
|
||||||
|
where move_type='D';
|
||||||
|
run;
|
||||||
%mp_stackdiffs(work.orig
|
%mp_stackdiffs(work.orig
|
||||||
,work.final
|
,work.final1
|
||||||
,CUSTOMER YEAR
|
,CUSTOMER YEAR
|
||||||
,mdebug=1
|
,mdebug=1
|
||||||
,errds=work.errds1
|
,errds=work.errds1
|
||||||
@@ -69,8 +73,12 @@ data work.orig2;
|
|||||||
set sashelp.electric;
|
set sashelp.electric;
|
||||||
if _n_ le 10;
|
if _n_ le 10;
|
||||||
run;
|
run;
|
||||||
|
data work.final2;
|
||||||
|
set work.final;
|
||||||
|
where move_type='D';
|
||||||
|
run;
|
||||||
%mp_stackdiffs(work.orig2
|
%mp_stackdiffs(work.orig2
|
||||||
,work.final
|
,work.final2
|
||||||
,CUSTOMER YEAR
|
,CUSTOMER YEAR
|
||||||
,mdebug=1
|
,mdebug=1
|
||||||
,errds=work.errds2
|
,errds=work.errds2
|
||||||
@@ -94,8 +102,12 @@ data work.orig3;
|
|||||||
set work.orig;
|
set work.orig;
|
||||||
stop;
|
stop;
|
||||||
run;
|
run;
|
||||||
|
data work.final3;
|
||||||
|
set work.final;
|
||||||
|
where move_type='A';
|
||||||
|
run;
|
||||||
%mp_stackdiffs(work.orig3
|
%mp_stackdiffs(work.orig3
|
||||||
,work.final
|
,work.final3
|
||||||
,CUSTOMER YEAR
|
,CUSTOMER YEAR
|
||||||
,mdebug=1
|
,mdebug=1
|
||||||
,errds=work.errds3
|
,errds=work.errds3
|
||||||
@@ -119,8 +131,12 @@ data work.orig4;
|
|||||||
set work.orig;
|
set work.orig;
|
||||||
if _n_>35 then stop;
|
if _n_>35 then stop;
|
||||||
run;
|
run;
|
||||||
|
data work.final4;
|
||||||
|
set work.final;
|
||||||
|
where move_type='A';
|
||||||
|
run;
|
||||||
%mp_stackdiffs(work.orig4
|
%mp_stackdiffs(work.orig4
|
||||||
,work.final
|
,work.final4
|
||||||
,CUSTOMER YEAR
|
,CUSTOMER YEAR
|
||||||
,mdebug=1
|
,mdebug=1
|
||||||
,errds=work.errds4
|
,errds=work.errds4
|
||||||
@@ -144,8 +160,12 @@ data work.orig5;
|
|||||||
set work.orig;
|
set work.orig;
|
||||||
drop Coal;
|
drop Coal;
|
||||||
run;
|
run;
|
||||||
|
data work.final5;
|
||||||
|
set work.final;
|
||||||
|
where move_type='A';
|
||||||
|
run;
|
||||||
%mp_stackdiffs(work.orig5
|
%mp_stackdiffs(work.orig5
|
||||||
,work.final
|
,work.final5
|
||||||
,CUSTOMER YEAR
|
,CUSTOMER YEAR
|
||||||
,mdebug=1
|
,mdebug=1
|
||||||
,errds=work.errds5
|
,errds=work.errds5
|
||||||
@@ -167,7 +187,7 @@ run;
|
|||||||
*/
|
*/
|
||||||
data work.final6;
|
data work.final6;
|
||||||
set work.final;
|
set work.final;
|
||||||
drop Coal;
|
where tgtvar_nm ne 'COAL' and move_type='A';
|
||||||
run;
|
run;
|
||||||
%mp_stackdiffs(work.orig
|
%mp_stackdiffs(work.orig
|
||||||
,work.final6
|
,work.final6
|
||||||
@@ -194,8 +214,12 @@ data work.orig7;
|
|||||||
set work.orig;
|
set work.orig;
|
||||||
drop Coal;
|
drop Coal;
|
||||||
run;
|
run;
|
||||||
|
data work.final7;
|
||||||
|
set work.final;
|
||||||
|
where move_type='M';
|
||||||
|
run;
|
||||||
%mp_stackdiffs(work.orig7
|
%mp_stackdiffs(work.orig7
|
||||||
,work.final
|
,work.final7
|
||||||
,CUSTOMER YEAR
|
,CUSTOMER YEAR
|
||||||
,mdebug=1
|
,mdebug=1
|
||||||
,errds=work.errds7
|
,errds=work.errds7
|
||||||
@@ -220,14 +244,16 @@ run;
|
|||||||
test=EQUALS 0
|
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;
|
data work.orig8;
|
||||||
set work.orig;
|
set work.orig;
|
||||||
if _n_ le 16;
|
if _n_ le 16;
|
||||||
run;
|
run;
|
||||||
%mp_stackdiffs(work.orig8
|
%mp_stackdiffs(work.orig8
|
||||||
,work.final7
|
,work.final
|
||||||
,CUSTOMER YEAR
|
,CUSTOMER YEAR
|
||||||
,mdebug=1
|
,mdebug=1
|
||||||
,errds=work.errds8
|
,errds=work.errds8
|
||||||
@@ -243,14 +269,6 @@ run;
|
|||||||
desc=Mod8 - 6 records populated (missing rows relevant),
|
desc=Mod8 - 6 records populated (missing rows relevant),
|
||||||
test=EQUALS 6
|
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?
|
* Modifications test - were diffs actually applied?
|
||||||
|
|||||||
@@ -15,7 +15,8 @@
|
|||||||
%mp_init()
|
%mp_init()
|
||||||
|
|
||||||
%macro loglevel();
|
%macro loglevel();
|
||||||
%if &_debug=2477 %then %do;
|
%if "&_debug"="2477" or "&_debug"="fields,log,trace" %then %do;
|
||||||
|
%put debug mode activated;
|
||||||
options mprint;
|
options mprint;
|
||||||
%end;
|
%end;
|
||||||
%mend loglevel;
|
%mend loglevel;
|
||||||
|
|||||||
Reference in New Issue
Block a user