Signed-off-by: weiyan <weiyan3@huawei.com>
| ... | ... |
@@ -37,9 +37,7 @@ func makefile(contents string) (string, func(), error) {
|
| 37 | 37 |
// attempt to contact any v1 registry endpoints. |
| 38 | 38 |
func (s *DockerRegistrySuite) TestV2Only(c *check.C) {
|
| 39 | 39 |
reg, err := newTestRegistry(c) |
| 40 |
- if err != nil {
|
|
| 41 |
- c.Fatal(err.Error()) |
|
| 42 |
- } |
|
| 40 |
+ c.Assert(err, check.IsNil) |
|
| 43 | 41 |
|
| 44 | 42 |
reg.registerHandler("/v2/", func(w http.ResponseWriter, r *http.Request) {
|
| 45 | 43 |
w.WriteHeader(404) |
| ... | ... |
@@ -52,14 +50,10 @@ func (s *DockerRegistrySuite) TestV2Only(c *check.C) {
|
| 52 | 52 |
repoName := fmt.Sprintf("%s/busybox", reg.hostport)
|
| 53 | 53 |
|
| 54 | 54 |
err = s.d.Start("--insecure-registry", reg.hostport, "--disable-legacy-registry=true")
|
| 55 |
- if err != nil {
|
|
| 56 |
- c.Fatalf("Error starting daemon: %s", err.Error())
|
|
| 57 |
- } |
|
| 55 |
+ c.Assert(err, check.IsNil) |
|
| 58 | 56 |
|
| 59 | 57 |
dockerfileName, cleanup, err := makefile(fmt.Sprintf("FROM %s/busybox", reg.hostport))
|
| 60 |
- if err != nil {
|
|
| 61 |
- c.Fatalf("Unable to create test dockerfile")
|
|
| 62 |
- } |
|
| 58 |
+ c.Assert(err, check.IsNil, check.Commentf("Unable to create test dockerfile"))
|
|
| 63 | 59 |
defer cleanup() |
| 64 | 60 |
|
| 65 | 61 |
s.d.Cmd("build", "--file", dockerfileName, ".")
|
| ... | ... |
@@ -76,9 +70,7 @@ func (s *DockerRegistrySuite) TestV2Only(c *check.C) {
|
| 76 | 76 |
// login, push, pull, build & run |
| 77 | 77 |
func (s *DockerRegistrySuite) TestV1(c *check.C) {
|
| 78 | 78 |
reg, err := newTestRegistry(c) |
| 79 |
- if err != nil {
|
|
| 80 |
- c.Fatal(err.Error()) |
|
| 81 |
- } |
|
| 79 |
+ c.Assert(err, check.IsNil) |
|
| 82 | 80 |
|
| 83 | 81 |
v2Pings := 0 |
| 84 | 82 |
reg.registerHandler("/v2/", func(w http.ResponseWriter, r *http.Request) {
|
| ... | ... |
@@ -107,42 +99,29 @@ func (s *DockerRegistrySuite) TestV1(c *check.C) {
|
| 107 | 107 |
}) |
| 108 | 108 |
|
| 109 | 109 |
err = s.d.Start("--insecure-registry", reg.hostport, "--disable-legacy-registry=false")
|
| 110 |
- if err != nil {
|
|
| 111 |
- c.Fatalf("Error starting daemon: %s", err.Error())
|
|
| 112 |
- } |
|
| 110 |
+ c.Assert(err, check.IsNil) |
|
| 113 | 111 |
|
| 114 | 112 |
dockerfileName, cleanup, err := makefile(fmt.Sprintf("FROM %s/busybox", reg.hostport))
|
| 115 |
- if err != nil {
|
|
| 116 |
- c.Fatalf("Unable to create test dockerfile")
|
|
| 117 |
- } |
|
| 113 |
+ c.Assert(err, check.IsNil, check.Commentf("Unable to create test dockerfile"))
|
|
| 118 | 114 |
defer cleanup() |
| 119 | 115 |
|
| 120 | 116 |
s.d.Cmd("build", "--file", dockerfileName, ".")
|
| 121 |
- if v1Repo == 0 {
|
|
| 122 |
- c.Errorf("Expected v1 repository access after build")
|
|
| 123 |
- } |
|
| 117 |
+ c.Assert(v1Repo, check.Not(check.Equals), 0, check.Commentf("Expected v1 repository access after build"))
|
|
| 124 | 118 |
|
| 125 | 119 |
repoName := fmt.Sprintf("%s/busybox", reg.hostport)
|
| 126 | 120 |
s.d.Cmd("run", repoName)
|
| 127 |
- if v1Repo == 1 {
|
|
| 128 |
- c.Errorf("Expected v1 repository access after run")
|
|
| 129 |
- } |
|
| 121 |
+ c.Assert(v1Repo, check.Not(check.Equals), 1, check.Commentf("Expected v1 repository access after run"))
|
|
| 130 | 122 |
|
| 131 | 123 |
s.d.Cmd("login", "-u", "richard", "-p", "testtest", "-e", "testuser@testdomain.com", reg.hostport)
|
| 132 |
- if v1Logins == 0 {
|
|
| 133 |
- c.Errorf("Expected v1 login attempt")
|
|
| 134 |
- } |
|
| 124 |
+ c.Assert(v1Logins, check.Not(check.Equals), 0, check.Commentf("Expected v1 login attempt"))
|
|
| 135 | 125 |
|
| 136 | 126 |
s.d.Cmd("tag", "busybox", repoName)
|
| 137 | 127 |
s.d.Cmd("push", repoName)
|
| 138 | 128 |
|
| 139 |
- if v1Repo != 2 || v1Pings != 1 {
|
|
| 140 |
- c.Error("Not all endpoints contacted after push", v1Repo, v1Pings)
|
|
| 141 |
- } |
|
| 129 |
+ c.Assert(v1Repo, check.Equals, 2) |
|
| 130 |
+ c.Assert(v1Pings, check.Equals, 1) |
|
| 142 | 131 |
|
| 143 | 132 |
s.d.Cmd("pull", repoName)
|
| 144 |
- if v1Repo != 3 {
|
|
| 145 |
- c.Errorf("Expected v1 repository access after pull")
|
|
| 146 |
- } |
|
| 133 |
+ c.Assert(v1Repo, check.Equals, 3, check.Commentf("Expected v1 repository access after pull"))
|
|
| 147 | 134 |
|
| 148 | 135 |
} |