Browse code

Using checkers assert for integration-cli/docker_cli_export_import_test.go

Signed-off-by: Mohammed Aaqib Ansari <maaquib@gmail.com>

Mohammed Aaqib Ansari authored on 2015/10/21 06:53:27
Showing 1 changed files
... ...
@@ -5,6 +5,7 @@ import (
5 5
 	"os/exec"
6 6
 	"strings"
7 7
 
8
+	"github.com/docker/docker/pkg/integration/checker"
8 9
 	"github.com/go-check/check"
9 10
 )
10 11
 
... ...
@@ -20,14 +21,10 @@ func (s *DockerSuite) TestExportContainerAndImportImage(c *check.C) {
20 20
 	importCmd := exec.Command(dockerBinary, "import", "-", "repo/testexp:v1")
21 21
 	importCmd.Stdin = strings.NewReader(out)
22 22
 	out, _, err := runCommandWithOutput(importCmd)
23
-	if err != nil {
24
-		c.Fatalf("failed to import image: %s, %v", out, err)
25
-	}
23
+	c.Assert(err, checker.IsNil, check.Commentf("failed to import image repo/testexp:v1: %s", out))
26 24
 
27 25
 	cleanedImageID := strings.TrimSpace(out)
28
-	if cleanedImageID == "" {
29
-		c.Fatalf("output should have been an image id, got: %s", out)
30
-	}
26
+	c.Assert(cleanedImageID, checker.Not(checker.Equals), "", check.Commentf("output should have been an image id"))
31 27
 }
32 28
 
33 29
 // Used to test output flag in the export command
... ...
@@ -40,19 +37,13 @@ func (s *DockerSuite) TestExportContainerWithOutputAndImportImage(c *check.C) {
40 40
 	defer os.Remove("testexp.tar")
41 41
 
42 42
 	out, _, err := runCommandWithOutput(exec.Command("cat", "testexp.tar"))
43
-	if err != nil {
44
-		c.Fatal(out, err)
45
-	}
43
+	c.Assert(err, checker.IsNil, check.Commentf(out))
46 44
 
47 45
 	importCmd := exec.Command(dockerBinary, "import", "-", "repo/testexp:v1")
48 46
 	importCmd.Stdin = strings.NewReader(out)
49 47
 	out, _, err = runCommandWithOutput(importCmd)
50
-	if err != nil {
51
-		c.Fatalf("failed to import image: %s, %v", out, err)
52
-	}
48
+	c.Assert(err, checker.IsNil, check.Commentf("failed to import image repo/testexp:v1: %s", out))
53 49
 
54 50
 	cleanedImageID := strings.TrimSpace(out)
55
-	if cleanedImageID == "" {
56
-		c.Fatalf("output should have been an image id, got: %s", out)
57
-	}
51
+	c.Assert(cleanedImageID, checker.Not(checker.Equals), "", check.Commentf("output should have been an image id"))
58 52
 }