@@ -10,13 +10,20 @@ maxrc=0
1010rc=0
1111export overrideWarningsEnabled=false
1212
13+ [[ $1 == ' update' ]] && {
14+ update=" true"
15+ echo " UPDATE MODE: CDK Snapshots will be updated. CDK UNIT TESTS WILL BE SKIPPED"
16+ } || update=" false"
17+
1318#! /bin/bash
1419echo ' Installing required Python testing modules'
1520pip install -r ./testing_requirements.txt
1621
1722# Get reference for all important folders
1823template_dir=" $PWD "
19- source_dir=" $template_dir /temp/source"
24+ source_dir=" $template_dir /../source"
25+ temp_source_dir=" $template_dir /temp/source"
26+
2027if [[ -e ' ./solution_env.sh' ]]; then
2128 chmod +x ./solution_env.sh
2229 source ./solution_env.sh
5057echo " ------------------------------------------------------------------------------"
5158echo " [Test] CDK Unit Tests - playbook CIS"
5259echo " ------------------------------------------------------------------------------"
53- cd $source_dir /playbooks/CIS
54- npm run test
55- rc=$?
56- echo CDK Unit Tests RC=$rc
57- if [ " $rc " -gt " $maxrc " ]; then
58- maxrc=$rc
59- fi
60+ cd $temp_source_dir /playbooks/CIS
61+ [[ $update == " true" ]] && {
62+ npm run test -- -u
63+ cp -f test/__snapshots__/* $source_dir /playbooks/CIS/test/__snapshots__/
64+ } || {
65+ npm run test
66+ rc=$?
67+ echo CDK Unit Tests RC=$rc
68+ if [ " $rc " -gt " $maxrc " ]; then
69+ maxrc=$rc
70+ fi
71+ }
6072
6173echo " ------------------------------------------------------------------------------"
6274echo " [Test] CDK Unit Tests - core"
6375echo " ------------------------------------------------------------------------------"
64- cd $source_dir /playbooks/core
76+ cd $temp_source_dir /playbooks/core
6577npm run test
6678rc=$?
6779echo CDK Unit Tests RC=$rc
7385echo " ------------------------------------------------------------------------------"
7486echo " [Test] CDK Unit Tests - solution_deploy"
7587echo " ------------------------------------------------------------------------------"
76- cd $source_dir /solution_deploy
77- npm run test
78- rc=$?
79- echo CDK Unit Tests RC=$rc
80- if [ " $rc " -gt " $maxrc " ]; then
81- maxrc=$rc
82- fi
88+ cd $temp_source_dir /solution_deploy
89+ [[ $update == " true" ]] && {
90+ npm run test -- -u
91+ cp -f test/__snapshots__/* $source_dir /solution_deploy/test/__snapshots__/
92+ } || {
93+ npm run test
94+ rc=$?
95+ echo CDK Unit Tests RC=$rc
96+ if [ " $rc " -gt " $maxrc " ]; then
97+ maxrc=$rc
98+ fi
99+ }
83100
84101echo " ------------------------------------------------------------------------------"
85102echo " [Test] Python Unit Tests"
0 commit comments