Переглянути джерело

Merge pull request #17222 from maaquib/16756-integration-cli-export-import-test

Using checkers assert for integration-cli/docker_cli_export_import_test.go
Antonio Murdaca 9 роки тому
батько
коміт
9328fc7e62
1 змінених файлів з 6 додано та 15 видалено
  1. 6 15
      integration-cli/docker_cli_export_import_test.go

+ 6 - 15
integration-cli/docker_cli_export_import_test.go

@@ -5,6 +5,7 @@ import (
 	"os/exec"
 	"os/exec"
 	"strings"
 	"strings"
 
 
+	"github.com/docker/docker/pkg/integration/checker"
 	"github.com/go-check/check"
 	"github.com/go-check/check"
 )
 )
 
 
@@ -20,14 +21,10 @@ func (s *DockerSuite) TestExportContainerAndImportImage(c *check.C) {
 	importCmd := exec.Command(dockerBinary, "import", "-", "repo/testexp:v1")
 	importCmd := exec.Command(dockerBinary, "import", "-", "repo/testexp:v1")
 	importCmd.Stdin = strings.NewReader(out)
 	importCmd.Stdin = strings.NewReader(out)
 	out, _, err := runCommandWithOutput(importCmd)
 	out, _, err := runCommandWithOutput(importCmd)
-	if err != nil {
-		c.Fatalf("failed to import image: %s, %v", out, err)
-	}
+	c.Assert(err, checker.IsNil, check.Commentf("failed to import image repo/testexp:v1: %s", out))
 
 
 	cleanedImageID := strings.TrimSpace(out)
 	cleanedImageID := strings.TrimSpace(out)
-	if cleanedImageID == "" {
-		c.Fatalf("output should have been an image id, got: %s", out)
-	}
+	c.Assert(cleanedImageID, checker.Not(checker.Equals), "", check.Commentf("output should have been an image id"))
 }
 }
 
 
 // Used to test output flag in the export command
 // Used to test output flag in the export command
@@ -40,19 +37,13 @@ func (s *DockerSuite) TestExportContainerWithOutputAndImportImage(c *check.C) {
 	defer os.Remove("testexp.tar")
 	defer os.Remove("testexp.tar")
 
 
 	out, _, err := runCommandWithOutput(exec.Command("cat", "testexp.tar"))
 	out, _, err := runCommandWithOutput(exec.Command("cat", "testexp.tar"))
-	if err != nil {
-		c.Fatal(out, err)
-	}
+	c.Assert(err, checker.IsNil, check.Commentf(out))
 
 
 	importCmd := exec.Command(dockerBinary, "import", "-", "repo/testexp:v1")
 	importCmd := exec.Command(dockerBinary, "import", "-", "repo/testexp:v1")
 	importCmd.Stdin = strings.NewReader(out)
 	importCmd.Stdin = strings.NewReader(out)
 	out, _, err = runCommandWithOutput(importCmd)
 	out, _, err = runCommandWithOutput(importCmd)
-	if err != nil {
-		c.Fatalf("failed to import image: %s, %v", out, err)
-	}
+	c.Assert(err, checker.IsNil, check.Commentf("failed to import image repo/testexp:v1: %s", out))
 
 
 	cleanedImageID := strings.TrimSpace(out)
 	cleanedImageID := strings.TrimSpace(out)
-	if cleanedImageID == "" {
-		c.Fatalf("output should have been an image id, got: %s", out)
-	}
+	c.Assert(cleanedImageID, checker.Not(checker.Equals), "", check.Commentf("output should have been an image id"))
 }
 }