fix tests, simplify and integrate credentials properly

This commit is contained in:
Simon Aronsson 2020-11-22 19:03:10 +01:00
parent 3d21ea683c
commit 24cf0fd6a3
No known key found for this signature in database
GPG key ID: 8DA57A5FD341605B
11 changed files with 209 additions and 141 deletions

View file

@ -17,6 +17,7 @@ func CreateMockContainer(id string, name string, image string, created time.Time
Created: created.String(),
},
Config: &container2.Config{
Image: image,
Labels: make(map[string]string),
},
}
@ -24,9 +25,38 @@ func CreateMockContainer(id string, name string, image string, created time.Time
&content,
&types.ImageInspect{
ID: image,
RepoDigests: []string{
image,
},
},
)
}
// CreateMockContainerWithImageInfo should only be used for testing
func CreateMockContainerWithImageInfo(id string, name string, image string, created time.Time, imageInfo types.ImageInspect) container.Container {
content := types.ContainerJSON{
ContainerJSONBase: &types.ContainerJSONBase{
ID: id,
Image: image,
Name: name,
Created: created.String(),
},
Config: &container2.Config{
Image: image,
Labels: make(map[string]string),
},
}
return *container.NewContainer(
&content,
&imageInfo,
)
}
// CreateMockContainerWithDigest should only be used for testing
func CreateMockContainerWithDigest(id string, name string, image string, created time.Time, digest string) container.Container {
c := CreateMockContainer(id, name, image, created)
c.ImageInfo().RepoDigests = []string{digest}
return c
}
// CreateMockContainerWithConfig creates a container substitute valid for testing
func CreateMockContainerWithConfig(id string, name string, image string, created time.Time, config *container2.Config) container.Container {