Skip to content

Commit

Permalink
add test for -thin-manifest-dir flag
Browse files Browse the repository at this point in the history
  • Loading branch information
Linus Arver committed Oct 11, 2019
1 parent c1ed41c commit c3239f1
Show file tree
Hide file tree
Showing 9 changed files with 181 additions and 1 deletion.
126 changes: 125 additions & 1 deletion lib/dockerregistry/inventory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,125 @@ func TestParseManifestsFromDir(t *testing.T) {
},
nil,
},
{
"Basic (multiple thin manifests)",
"basic-thin",
[]Manifest{
{
Registries: []RegistryContext{
{
Name: "gcr.io/foo-staging",
ServiceAccount: "sa@robot.com",
Src: true,
},
{
Name: "us.gcr.io/some-prod",
ServiceAccount: "sa@robot.com",
},
{
Name: "eu.gcr.io/some-prod",
ServiceAccount: "sa@robot.com",
},
{
Name: "asia.gcr.io/some-prod",
ServiceAccount: "sa@robot.com",
},
},
Images: []Image{
{ImageName: "foo-controller",
Dmap: DigestTags{
"sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa": {"1.0"},
},
},
},
filepath: "thin-manifests/a/promoter-manifest.yaml"},
{
Registries: []RegistryContext{
{
Name: "gcr.io/cat-staging",
ServiceAccount: "sa@robot.com",
Src: true,
},
{
Name: "us.gcr.io/some-prod",
ServiceAccount: "sa@robot.com",
},
{
Name: "eu.gcr.io/some-prod",
ServiceAccount: "sa@robot.com",
},
{
Name: "asia.gcr.io/some-prod",
ServiceAccount: "sa@robot.com",
},
},
Images: []Image{
{ImageName: "cat-controller",
Dmap: DigestTags{
"sha256:cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc": {"1.0"},
},
},
},
filepath: "thin-manifests/b/c/promoter-manifest.yaml"},
{
Registries: []RegistryContext{
{
Name: "gcr.io/bar-staging",
ServiceAccount: "sa@robot.com",
Src: true,
},
{
Name: "us.gcr.io/some-prod",
ServiceAccount: "sa@robot.com",
},
{
Name: "eu.gcr.io/some-prod",
ServiceAccount: "sa@robot.com",
},
{
Name: "asia.gcr.io/some-prod",
ServiceAccount: "sa@robot.com",
},
},
Images: []Image{
{ImageName: "bar-controller",
Dmap: DigestTags{
"sha256:bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb": {"1.0"},
},
},
},
filepath: "thin-manifests/b/promoter-manifest.yaml"},
{
Registries: []RegistryContext{
{
Name: "gcr.io/qux-staging",
ServiceAccount: "sa@robot.com",
Src: true,
},
{
Name: "us.gcr.io/some-prod",
ServiceAccount: "sa@robot.com",
},
{
Name: "eu.gcr.io/some-prod",
ServiceAccount: "sa@robot.com",
},
{
Name: "asia.gcr.io/some-prod",
ServiceAccount: "sa@robot.com",
},
},
Images: []Image{
{ImageName: "qux-controller",
Dmap: DigestTags{
"sha256:0000000000000000000000000000000000000000000000000000000000000000": {"1.0"},
},
},
},
filepath: "thin-manifests/promoter-manifest.yaml"},
},
nil,
},
}

for _, test := range tests {
Expand All @@ -512,7 +631,12 @@ func TestParseManifestsFromDir(t *testing.T) {
expectedModified = append(expectedModified, mfest)
}

got, err := ParseManifestsFromDir(fixtureDir, ParseManifestFromFile)
parseManifestFunc := ParseManifestFromFile
if test.input == "basic-thin" {
parseManifestFunc = ParseThinManifestFromFile
}

got, err := ParseManifestsFromDir(fixtureDir, parseManifestFunc)

// Clear private fields (redundant data) that are calculated on-the-fly
// (it's too verbose to include them here; besides, it's not what we're
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- name: foo-controller
dmap:
"sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa": ["1.0"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- name: bar-controller
dmap:
"sha256:bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb": ["1.0"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- name: cat-controller
dmap:
"sha256:cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc": ["1.0"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- name: qux-controller
dmap:
"sha256:0000000000000000000000000000000000000000000000000000000000000000": ["1.0"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
registries:
- name: gcr.io/foo-staging
service-account: sa@robot.com
src: true
- name: us.gcr.io/some-prod
service-account: sa@robot.com
- name: eu.gcr.io/some-prod
service-account: sa@robot.com
- name: asia.gcr.io/some-prod
service-account: sa@robot.com
imagesPath: "../../images/a.yaml"
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
registries:
- name: gcr.io/cat-staging
service-account: sa@robot.com
src: true
- name: us.gcr.io/some-prod
service-account: sa@robot.com
- name: eu.gcr.io/some-prod
service-account: sa@robot.com
- name: asia.gcr.io/some-prod
service-account: sa@robot.com
imagesPath: "../../../images/bc.yaml"
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
registries:
- name: gcr.io/bar-staging
service-account: sa@robot.com
src: true
- name: us.gcr.io/some-prod
service-account: sa@robot.com
- name: eu.gcr.io/some-prod
service-account: sa@robot.com
- name: asia.gcr.io/some-prod
service-account: sa@robot.com
imagesPath: "../../images/b.yaml"
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
registries:
- name: gcr.io/qux-staging
service-account: sa@robot.com
src: true
- name: us.gcr.io/some-prod
service-account: sa@robot.com
- name: eu.gcr.io/some-prod
service-account: sa@robot.com
- name: asia.gcr.io/some-prod
service-account: sa@robot.com
imagesPath: "../images/root.yaml"

0 comments on commit c3239f1

Please sign in to comment.