@@ -352,23 +352,55 @@ def test_parse_host_empty_value(self):
352352 assert parse_host (val , 'win32' ) == tcp_port
353353
354354
355+ class ParseRepositoryTagTest (base .BaseTestCase ):
356+ sha = 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'
357+
358+ def test_index_image_no_tag (self ):
359+ self .assertEqual (
360+ parse_repository_tag ("root" ), ("root" , None )
361+ )
362+
363+ def test_index_image_tag (self ):
364+ self .assertEqual (
365+ parse_repository_tag ("root:tag" ), ("root" , "tag" )
366+ )
367+
368+ def test_index_user_image_no_tag (self ):
369+ self .assertEqual (
370+ parse_repository_tag ("user/repo" ), ("user/repo" , None )
371+ )
372+
373+ def test_index_user_image_tag (self ):
374+ self .assertEqual (
375+ parse_repository_tag ("user/repo:tag" ), ("user/repo" , "tag" )
376+ )
377+
378+ def test_private_reg_image_no_tag (self ):
379+ self .assertEqual (
380+ parse_repository_tag ("url:5000/repo" ), ("url:5000/repo" , None )
381+ )
382+
383+ def test_private_reg_image_tag (self ):
384+ self .assertEqual (
385+ parse_repository_tag ("url:5000/repo:tag" ), ("url:5000/repo" , "tag" )
386+ )
387+
388+ def test_index_image_sha (self ):
389+ self .assertEqual (
390+ parse_repository_tag ("root@sha256:{0}" .format (self .sha )),
391+ ("root" , "sha256:{0}" .format (self .sha ))
392+ )
393+
394+ def test_private_reg_image_sha (self ):
395+ self .assertEqual (
396+ parse_repository_tag ("url:5000/repo@sha256:{0}" .format (self .sha )),
397+ ("url:5000/repo" , "sha256:{0}" .format (self .sha ))
398+ )
399+
400+
355401class UtilsTest (base .BaseTestCase ):
356402 longMessage = True
357403
358- def test_parse_repository_tag (self ):
359- self .assertEqual (parse_repository_tag ("root" ),
360- ("root" , None ))
361- self .assertEqual (parse_repository_tag ("root:tag" ),
362- ("root" , "tag" ))
363- self .assertEqual (parse_repository_tag ("user/repo" ),
364- ("user/repo" , None ))
365- self .assertEqual (parse_repository_tag ("user/repo:tag" ),
366- ("user/repo" , "tag" ))
367- self .assertEqual (parse_repository_tag ("url:5000/repo" ),
368- ("url:5000/repo" , None ))
369- self .assertEqual (parse_repository_tag ("url:5000/repo:tag" ),
370- ("url:5000/repo" , "tag" ))
371-
372404 def test_parse_bytes (self ):
373405 self .assertEqual (parse_bytes ("512MB" ), (536870912 ))
374406 self .assertEqual (parse_bytes ("512M" ), (536870912 ))
0 commit comments