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

Commit e590619

Browse files
committed
add integration test
1 parent 7ca26a9 commit e590619

File tree

4 files changed

+31
-3
lines changed

4 files changed

+31
-3
lines changed

cmd/analyze.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ func analyzeImage(imageName string, analyzerArgs []string) error {
8787
return fmt.Errorf("Error performing image analysis: %s", err)
8888
}
8989

90-
output.PrintToStdErr("Retrieving analyses")
90+
output.PrintToStdErr("Retrieving analyses\n")
9191
outputResults(analyses)
9292

9393
if save {

cmd/diff.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ func diffImages(image1Arg, image2Arg string, diffArgs []string) error {
113113
defer pkgutil.CleanupImage(*imageMap[image2Arg])
114114
}
115115

116-
output.PrintToStdErr("Computing diffs")
116+
output.PrintToStdErr("Computing diffs\n")
117117
req := differs.DiffRequest{
118118
Image1: *imageMap[image1Arg],
119119
Image2: *imageMap[image2Arg],
@@ -125,7 +125,7 @@ func diffImages(image1Arg, image2Arg string, diffArgs []string) error {
125125
outputResults(diffs)
126126

127127
if filename != "" {
128-
output.PrintToStdErr("Computing filename diffs")
128+
output.PrintToStdErr("Computing filename diffs\n")
129129
err := diffFile(imageMap[image1Arg], imageMap[image2Arg])
130130
if err != nil {
131131
return err

tests/integration_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ const (
3939
diffBase = "gcr.io/gcp-runtimes/diff-base"
4040
diffModified = "gcr.io/gcp-runtimes/diff-modified"
4141

42+
metadataBase = "gcr.io/gcp-runtimes/metadata-base"
43+
metadataModified = "gcr.io/gcp-runtimes/metadata-modified"
44+
4245
aptBase = "gcr.io/gcp-runtimes/apt-base"
4346
aptModified = "gcr.io/gcp-runtimes/apt-modified"
4447

@@ -152,6 +155,14 @@ func TestDiffAndAnalysis(t *testing.T) {
152155
differFlags: []string{"--type=history"},
153156
expectedFile: "hist_diff_expected.json",
154157
},
158+
{
159+
description: "metadata differ",
160+
subcommand: "diff",
161+
imageA: metadataBase,
162+
imageB: metadataModified,
163+
differFlags: []string{"--type=metadata"},
164+
expectedFile: "metadata_diff_expected.json",
165+
},
155166
{
156167
description: "apt sorted differ",
157168
subcommand: "diff",

tests/metadata_diff_expected.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[
2+
{
3+
"Image1": "gcr.io/gcp-runtimes/metadata-base:latest",
4+
"Image2": "gcr.io/gcp-runtimes/metadata-modified:latest",
5+
"DiffType": "Metadata",
6+
"Diff": {
7+
"Adds": [
8+
"Entrypoint: /entrypoint",
9+
"ExposedPorts: map[1234/tcp:{}]"
10+
],
11+
"Dels": [
12+
"Entrypoint: ",
13+
"ExposedPorts: map[1234/tcp:{} 4321/tcp:{}]"
14+
]
15+
}
16+
}
17+
]

0 commit comments

Comments
 (0)