docker_cli_push_test.go 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. package main
  2. import (
  3. "fmt"
  4. "os/exec"
  5. "testing"
  6. )
  7. // these tests need a freshly started empty private docker registry
  8. // pulling an image from the central registry should work
  9. func TestPushBusyboxImage(t *testing.T) {
  10. // skip this test until we're able to use a registry
  11. t.Skip()
  12. // tag the image to upload it tot he private registry
  13. repoName := fmt.Sprintf("%v/busybox", privateRegistryURL)
  14. tagCmd := exec.Command(dockerBinary, "tag", "busybox", repoName)
  15. out, exitCode, err := runCommandWithOutput(tagCmd)
  16. errorOut(err, t, fmt.Sprintf("%v %v", out, err))
  17. if err != nil || exitCode != 0 {
  18. t.Fatal("image tagging failed")
  19. }
  20. pushCmd := exec.Command(dockerBinary, "push", repoName)
  21. out, exitCode, err = runCommandWithOutput(pushCmd)
  22. errorOut(err, t, fmt.Sprintf("%v %v", out, err))
  23. deleteImages(repoName)
  24. if err != nil || exitCode != 0 {
  25. t.Fatal("pushing the image to the private registry has failed")
  26. }
  27. logDone("push - push busybox to private registry")
  28. }
  29. // pushing an image without a prefix should throw an error
  30. func TestPushUnprefixedRepo(t *testing.T) {
  31. // skip this test until we're able to use a registry
  32. t.Skip()
  33. pushCmd := exec.Command(dockerBinary, "push", "busybox")
  34. _, exitCode, err := runCommandWithOutput(pushCmd)
  35. if err == nil || exitCode == 0 {
  36. t.Fatal("pushing an unprefixed repo didn't result in a non-zero exit status")
  37. }
  38. logDone("push - push unprefixed busybox repo --> must fail")
  39. }