GitOps for k8s
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

spec_test.go 675B

123456789101112131415161718192021222324
  1. package update
  2. import "testing"
  3. func TestParseImageSpec(t *testing.T) {
  4. parseSpec(t, "valid/image:tag", false)
  5. parseSpec(t, "image:tag", false)
  6. parseSpec(t, ":tag", true)
  7. parseSpec(t, "image:", true)
  8. parseSpec(t, "image", true)
  9. parseSpec(t, string(ImageSpecLatest), false)
  10. parseSpec(t, "<invalid spec>", true)
  11. }
  12. func parseSpec(t *testing.T, image string, expectError bool) {
  13. spec, err := ParseImageSpec(image)
  14. isErr := (err != nil)
  15. if isErr != expectError {
  16. t.Fatalf("Expected error = %v for %q. Error = %q\n", expectError, image, err)
  17. }
  18. if !expectError && (string(spec) != image) {
  19. t.Fatalf("Expected string spec %q but got %q", image, string(spec))
  20. }
  21. }