Skip to content

Commit

Permalink
Merge pull request #1404 from fuweid/checkpick_issue_1397
Browse files Browse the repository at this point in the history
bugfix: use the stable image ID in test
  • Loading branch information
HusterWan authored May 24, 2018
2 parents b9cd0fc + f92d066 commit 15ab49d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
20 changes: 14 additions & 6 deletions test/api_image_inspect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,27 @@ func init() {
// SetUpTest does common setup in the beginning of each test.
func (suite *APIImageInspectSuite) SetUpTest(c *check.C) {
SkipIfFalse(c, environment.IsLinux)
PullImage(c, busyboxImage)
PullImage(c, fmt.Sprintf("%s:%s", environment.BusyboxRepo, "1.24"))
}

// TestImageInspectOk tests inspecting images is OK.
func (suite *APIImageInspectSuite) TestImageInspectOk(c *check.C) {
repoID := environment.BusyboxID
repoTag, repoDigest := busyboxImage, fmt.Sprintf("%s@%s", environment.BusyboxRepo, environment.BusyboxDigest)
var (
repo = environment.BusyboxRepo
tag = "1.24"

id = "sha256:ca3d7d608b8a8bbaaac2c350bd0f9588cce0509ada74108d5c4b2afb24c46125"
dig = "sha256:840f2b98a2540ff1d265782c42543dbec7218d3ab0e73b296d7dac846f146e27"
)

repoTag := fmt.Sprintf("%s:%s", repo, tag)
repoDigest := fmt.Sprintf("%s@%s", repo, dig)

for _, image := range []string{
repoID,
id,
repoTag,
repoDigest,
fmt.Sprintf("%s:whatever@%s", environment.BusyboxRepo, environment.BusyboxDigest),
fmt.Sprintf("%s:whatever@%s", repo, dig),
} {
resp, err := request.Get("/images/" + image + "/json")
c.Assert(err, check.IsNil)
Expand All @@ -45,7 +53,7 @@ func (suite *APIImageInspectSuite) TestImageInspectOk(c *check.C) {

// TODO: More specific check is needed
c.Assert(got.Config, check.NotNil)
c.Assert(got.ID, check.Equals, repoID)
c.Assert(got.ID, check.Equals, id)
c.Assert(got.CreatedAt, check.NotNil)
c.Assert(got.Size, check.NotNil)
c.Assert(reflect.DeepEqual(got.RepoTags, []string{repoTag}), check.Equals, true)
Expand Down
6 changes: 0 additions & 6 deletions test/environment/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,9 @@ var (
// BusyboxRepo the repository of busybox image
BusyboxRepo = "registry.hub.docker.com/library/busybox"

// BusyboxID the digest ID used for busybox image
BusyboxID = "sha256:8ac48589692a53a9b8c2d1ceaa6b402665aa7fe667ba51ccc03002300856d8c7"

// BusyboxTag the tag used for busybox image
BusyboxTag = "1.28"

// BusyboxDigest the digest used for busybox image
BusyboxDigest = "sha256:58ac43b2cc92c687a32c8be6278e50a063579655fe3090125dcb2af0ff9e1a64"

// HelloworldRepo the repository of hello-world image
HelloworldRepo = "registry.hub.docker.com/library/hello-world"

Expand Down

0 comments on commit 15ab49d

Please sign in to comment.