docker_cli_pull_test.go 908 B

123456789101112131415161718192021222324252627282930
  1. package main
  2. import (
  3. "fmt"
  4. "os/exec"
  5. "testing"
  6. )
  7. // pulling an image from the central registry should work
  8. func TestPullImageFromCentralRegistry(t *testing.T) {
  9. pullCmd := exec.Command(dockerBinary, "pull", "busybox:latest")
  10. out, exitCode, err := runCommandWithOutput(pullCmd)
  11. errorOut(err, t, fmt.Sprintf("%s %s", out, err))
  12. if err != nil || exitCode != 0 {
  13. t.Fatal("pulling the busybox image from the registry has failed")
  14. }
  15. logDone("pull - pull busybox")
  16. }
  17. // pulling a non-existing image from the central registry should return a non-zero exit code
  18. func TestPullNonExistingImage(t *testing.T) {
  19. pullCmd := exec.Command(dockerBinary, "pull", "fooblahblah1234")
  20. _, exitCode, err := runCommandWithOutput(pullCmd)
  21. if err == nil || exitCode == 0 {
  22. t.Fatal("expected non-zero exit status when pulling non-existing image")
  23. }
  24. logDone("pull - pull fooblahblah1234 (non-existing image)")
  25. }