Add inline-comparison as acceptance test (#130)

* add inline-compare as acceptance test

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>

* add additional RPM metadata

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>

* add comments and doc strings to the compare-* make targets

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>
This commit is contained in:
Alex Goodman
2020-08-10 10:33:44 -04:00
committed by GitHub
parent 4c7784da62
commit 2d452bf59e
17 changed files with 274 additions and 112 deletions
+11 -5
View File
@@ -45,12 +45,18 @@ func parseRpmDB(_ string, reader io.Reader) ([]pkg.Package, error) {
for _, entry := range pkgList {
p := pkg.Package{
Name: entry.Name,
Version: entry.Version,
Type: pkg.RpmPkg,
Version: fmt.Sprintf("%s-%s", entry.Version, entry.Release), // this is what engine does
//Version: fmt.Sprintf("%d:%s-%s.%s", entry.Epoch, entry.Version, entry.Release, entry.Arch),
Type: pkg.RpmPkg,
Metadata: pkg.RpmMetadata{
Epoch: entry.Epoch,
Arch: entry.Arch,
Release: entry.Release,
Version: entry.Version,
Epoch: entry.Epoch,
Arch: entry.Arch,
Release: entry.Release,
SourceRpm: entry.SourceRpm,
Vendor: entry.Vendor,
License: entry.License,
Size: entry.Size,
},
}
+11 -6
View File
@@ -11,12 +11,17 @@ func TestParseRpmDB(t *testing.T) {
expected := map[string]pkg.Package{
"dive": {
Name: "dive",
Version: "0.9.2",
Version: "0.9.2-1",
Type: pkg.RpmPkg,
Metadata: pkg.RpmMetadata{
Epoch: 0,
Arch: "x86_64",
Release: "1",
Epoch: 0,
Arch: "x86_64",
Release: "1",
Version: "0.9.2",
SourceRpm: "dive-0.9.2-1.src.rpm",
Size: 12406784,
License: "MIT",
Vendor: "",
},
},
}
@@ -31,11 +36,11 @@ func TestParseRpmDB(t *testing.T) {
t.Fatalf("failed to parse rpmdb: %+v", err)
}
if len(actual) != 1 {
if len(actual) != len(expected) {
for _, a := range actual {
t.Log(" ", a)
}
t.Fatalf("unexpected package count: %d!=%d", len(actual), 1)
t.Fatalf("unexpected package count: %d!=%d", len(actual), len(expected))
}
for _, a := range actual {
@@ -1,7 +1,7 @@
#!/usr/bin/env bash
set -eux
docker create --name generate-rpmdb-fixture centos:latest sh -c 'tail -f /dev/null'
docker create --name generate-rpmdb-fixture centos:8 sh -c 'tail -f /dev/null'
function cleanup {
docker kill generate-rpmdb-fixture
+8 -4
View File
@@ -10,10 +10,14 @@ type DpkgMetadata struct {
}
type RpmMetadata struct {
Epoch int `mapstructure:"Epoch" json:"epoch"`
Arch string `mapstructure:"Arch" json:"architecture"`
Release string `mapstructure:"Release" json:"release"`
// TODO: consider keeping the remaining values as an embedded map
Version string `mapstructure:"Version" json:"version"`
Epoch int `mapstructure:"Epoch" json:"epoch"`
Arch string `mapstructure:"Arch" json:"architecture"`
Release string `mapstructure:"Release" json:"release"`
SourceRpm string `mapstructure:"SourceRpm" json:"source-rpm"`
Size int `mapstructure:"Size" json:"size"`
License string `mapstructure:"License" json:"license"`
Vendor string `mapstructure:"Vendor" json:"vendor"`
}
type JavaManifest struct {