Skip to content
This repository was archived by the owner on Mar 27, 2024. It is now read-only.

Commit b453dd4

Browse files
committed
Updated integration tests
1 parent 9d4ef87 commit b453dd4

11 files changed

+500
-184
lines changed

.container-diff-tests.sh

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,19 @@ while IFS=$' \n\r' read -r flag differ image1 image2 file; do
77
fi
88
done < tests/differ_runs.txt
99

10+
while IFS=$' \n\r' read -r flag analyzer image file; do
11+
go run main.go $image $flag -j > $file
12+
if [[ $? -ne 0 ]]; then
13+
echo "container-diff" "$analyzer" "analyzer failed"
14+
exit 1
15+
fi
16+
done < tests/analyzer_runs.txt
17+
1018
success=0
11-
while IFS=$' \n\r' read -r differ actual expected; do
19+
while IFS=$' \n\r' read -r type analyzer actual expected; do
1220
diff=$(jq --argfile a "$actual" --argfile b "$expected" -n 'def walk(f): . as $in | if type == "object" then reduce keys[] as $key ( {}; . + { ($key): ($in[$key] | walk(f)) } ) | f elif type == "array" then map( walk(f) ) | f else f end; ($a | walk(if type == "array" then sort else . end)) as $a | ($b | walk(if type == "array" then sort else . end)) as $b | $a == $b')
1321
if ! "$diff" ; then
14-
echo "container-diff" "$differ" "diff output is not as expected"
22+
echo "container-diff" "$analyzer" "$type" "output is not as expected"
1523
success=1
1624
fi
1725
done < tests/diff_comparisons.txt

cmd/root.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ func analyzeImage(imageArg string, analyzerArgs []string) error {
216216
}
217217

218218
func cleanupImage(image utils.Image) {
219-
if reflect.DeepEqual(image, (utils.Image{})) {
219+
if !reflect.DeepEqual(image, (utils.Image{})) {
220220
glog.Infof("Removing image filesystem directory %s from system", image.FSPath)
221221
errMsg := remove(image.FSPath, true)
222222
if errMsg != "" {

tests/analyzer_runs.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
-p pip gcr.io/gcp-runtimes/pip-modified tests/pip_analysis_actual.json
2+
-a apt gcr.io/gcp-runtimes/apt-modified tests/apt_analysis_actual.json
3+
-n node gcr.io/gcp-runtimes/node-modified tests/node_analysis_actual.json

0 commit comments

Comments
 (0)