docker_cli_push_test.go 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. if out, _, err := runCommandWithOutput(tagCmd); err != nil {
  16. t.Fatalf("image tagging failed: %s, %v", out, err)
  17. }
  18. pushCmd := exec.Command(dockerBinary, "push", repoName)
  19. if out, _, err := runCommandWithOutput(pushCmd); err != nil {
  20. t.Fatalf("pushing the image to the private registry has failed: %s, %v", out, err)
  21. }
  22. deleteImages(repoName)
  23. logDone("push - push busybox to private registry")
  24. }
  25. // pushing an image without a prefix should throw an error
  26. func TestPushUnprefixedRepo(t *testing.T) {
  27. // skip this test until we're able to use a registry
  28. t.Skip()
  29. pushCmd := exec.Command(dockerBinary, "push", "busybox")
  30. if out, _, err := runCommandWithOutput(pushCmd); err == nil {
  31. t.Fatalf("pushing an unprefixed repo didn't result in a non-zero exit status: %s", out)
  32. }
  33. logDone("push - push unprefixed busybox repo --> must fail")
  34. }