@@ -291,8 +291,7 @@ func TestReferenceParse(t *testing.T) {
291291 if named .Name () != tc .repository {
292292 t .Errorf ("unexpected repository: got %q, expected %q" , named .Name (), tc .repository )
293293 }
294- domain , _ := SplitHostname (named )
295- if domain != tc .domain {
294+ if domain := Domain (named ); domain != tc .domain {
296295 t .Errorf ("unexpected domain: got %q, expected %q" , domain , tc .domain )
297296 }
298297 } else if tc .repository != "" || tc .domain != "" {
@@ -373,42 +372,42 @@ func TestWithNameFailure(t *testing.T) {
373372 }
374373}
375374
376- func TestSplitHostname (t * testing.T ) {
375+ func TestDomainAndPath (t * testing.T ) {
377376 t .Parallel ()
378377 tests := []struct {
379378 input string
380379 domain string
381- name string
380+ path string
382381 }{
383382 {
384383 input : "test.com/foo" ,
385384 domain : "test.com" ,
386- name : "foo" ,
385+ path : "foo" ,
387386 },
388387 {
389388 input : "test_com/foo" ,
390389 domain : "" ,
391- name : "test_com/foo" ,
390+ path : "test_com/foo" ,
392391 },
393392 {
394393 input : "test:8080/foo" ,
395394 domain : "test:8080" ,
396- name : "foo" ,
395+ path : "foo" ,
397396 },
398397 {
399398 input : "test.com:8080/foo" ,
400399 domain : "test.com:8080" ,
401- name : "foo" ,
400+ path : "foo" ,
402401 },
403402 {
404403 input : "test-com:8080/foo" ,
405404 domain : "test-com:8080" ,
406- name : "foo" ,
405+ path : "foo" ,
407406 },
408407 {
409408 input : "xn--n3h.com:18080/foo" ,
410409 domain : "xn--n3h.com:18080" ,
411- name : "foo" ,
410+ path : "foo" ,
412411 },
413412 }
414413 for _ , tc := range tests {
@@ -419,12 +418,11 @@ func TestSplitHostname(t *testing.T) {
419418 if err != nil {
420419 t .Errorf ("error parsing name: %s" , err )
421420 }
422- domain , name := SplitHostname (named )
423- if domain != tc .domain {
421+ if domain := Domain (named ); domain != tc .domain {
424422 t .Errorf ("unexpected domain: got %q, expected %q" , domain , tc .domain )
425423 }
426- if name != tc .name {
427- t .Errorf ("unexpected name: got %q, expected %q" , name , tc .name )
424+ if path := Path ( named ); path != tc .path {
425+ t .Errorf ("unexpected name: got %q, expected %q" , path , tc .path )
428426 }
429427 })
430428 }
@@ -681,18 +679,18 @@ func TestParseNamed(t *testing.T) {
681679 tests := []struct {
682680 input string
683681 domain string
684- name string
682+ path string
685683 err error
686684 }{
687685 {
688686 input : "test.com/foo" ,
689687 domain : "test.com" ,
690- name : "foo" ,
688+ path : "foo" ,
691689 },
692690 {
693691 input : "test:8080/foo" ,
694692 domain : "test:8080" ,
695- name : "foo" ,
693+ path : "foo" ,
696694 },
697695 {
698696 input : "test_com/foo" ,
@@ -713,7 +711,7 @@ func TestParseNamed(t *testing.T) {
713711 {
714712 input : "docker.io/library/foo" ,
715713 domain : "docker.io" ,
716- name : "library/foo" ,
714+ path : "library/foo" ,
717715 },
718716 // Ambiguous case, parser will add "library/" to foo
719717 {
@@ -739,12 +737,11 @@ func TestParseNamed(t *testing.T) {
739737 return
740738 }
741739
742- domain , name := SplitHostname (named )
743- if domain != tc .domain {
740+ if domain := Domain (named ); domain != tc .domain {
744741 t .Errorf ("unexpected domain: got %q, expected %q" , domain , tc .domain )
745742 }
746- if name != tc .name {
747- t .Errorf ("unexpected name: got %q, expected %q" , name , tc .name )
743+ if path := Path ( named ); path != tc .path {
744+ t .Errorf ("unexpected name: got %q, expected %q" , path , tc .path )
748745 }
749746 })
750747 }
0 commit comments