@@ -36,19 +36,14 @@ func TestCopyFileWithInvalidDest(t *testing.T) {
3636func TestCanonicalTarNameForPath (t * testing.T ) {
3737 cases := []struct {
3838 in , expected string
39- shouldFail bool
4039 }{
41- {"foo" , "foo" , false },
42- {"foo/bar" , "___" , true }, // unix-styled windows path must fail
43- {`foo\bar` , "foo/bar" , false },
40+ {"foo" , "foo" },
41+ {"foo/bar" , "foo/bar" },
42+ {`foo\bar` , "foo/bar" },
4443 }
4544 for _ , v := range cases {
46- if out , err := CanonicalTarNameForPath (v .in ); err != nil && ! v .shouldFail {
47- t .Fatalf ("cannot get canonical name for path: %s: %v" , v .in , err )
48- } else if v .shouldFail && err == nil {
49- t .Fatalf ("canonical path call should have failed with error. in=%s out=%s" , v .in , out )
50- } else if ! v .shouldFail && out != v .expected {
51- t .Fatalf ("wrong canonical tar name. expected:%s got:%s" , v .expected , out )
45+ if CanonicalTarNameForPath (v .in ) != v .expected {
46+ t .Fatalf ("wrong canonical tar name. expected:%s got:%s" , v .expected , CanonicalTarNameForPath (v .in ))
5247 }
5348 }
5449}
@@ -65,10 +60,8 @@ func TestCanonicalTarName(t *testing.T) {
6560 {`foo\bar` , true , "foo/bar/" },
6661 }
6762 for _ , v := range cases {
68- if out , err := canonicalTarName (v .in , v .isDir ); err != nil {
69- t .Fatalf ("cannot get canonical name for path: %s: %v" , v .in , err )
70- } else if out != v .expected {
71- t .Fatalf ("wrong canonical tar name. expected:%s got:%s" , v .expected , out )
63+ if canonicalTarName (v .in , v .isDir ) != v .expected {
64+ t .Fatalf ("wrong canonical tar name. expected:%s got:%s" , v .expected , canonicalTarName (v .in , v .isDir ))
7265 }
7366 }
7467}
0 commit comments