From dd6e73bf0c1ba09789d01d797ded176c04498958 Mon Sep 17 00:00:00 2001 From: yige Date: Fri, 9 Aug 2019 17:08:37 +0800 Subject: [PATCH] add windows test --- unzip_test.go | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/unzip_test.go b/unzip_test.go index bf3b4e0..f4961de 100644 --- a/unzip_test.go +++ b/unzip_test.go @@ -17,7 +17,7 @@ func currentDir() string { } func testNullContent(t *testing.T) { - aFile, err := os.Open(path.Join(currentDir(), "./test/a.txt")) + aFile, err := os.Open(filepath.FromSlash(path.Join(currentDir(), "./test/a.txt"))) if err != nil { t.Fatal(err) } @@ -28,7 +28,7 @@ func testNullContent(t *testing.T) { t.Fatal(err) } - aOutFile, err := os.Open(path.Join(currentDir(), "./test/out/a.txt")) + aOutFile, err := os.Open(filepath.FromSlash(path.Join(currentDir(), "./test/out/a.txt"))) if err != nil { t.Fatal(err) } @@ -49,7 +49,7 @@ func testNullContent(t *testing.T) { } func testContentEqual(t *testing.T) { - bFile, err := os.Open(path.Join(currentDir(), "./test/b.txt")) + bFile, err := os.Open(filepath.FromSlash(path.Join(currentDir(), "./test/b.txt"))) if err != nil { t.Fatal(err) } @@ -60,7 +60,7 @@ func testContentEqual(t *testing.T) { t.Fatal(err) } - bOutFile, err := os.Open(path.Join(currentDir(), "./test/out/b.txt")) + bOutFile, err := os.Open(filepath.FromSlash(path.Join(currentDir(), "./test/out/b.txt"))) if err != nil { t.Fatal(err) } @@ -79,7 +79,7 @@ func testContentEqual(t *testing.T) { } func testLink(t *testing.T) { - cOutFile, err := os.OpenFile(path.Join(currentDir(), "./test/out/c.txt"), os.O_RDWR|os.O_CREATE|os.O_APPEND, 0644) + cOutFile, err := os.OpenFile(filepath.FromSlash(path.Join(currentDir(), "./test/out/c.txt")), os.O_RDWR|os.O_CREATE|os.O_APPEND, 0644) if err != nil { t.Fatal(err) } @@ -90,7 +90,7 @@ func testLink(t *testing.T) { t.Fatal(err) } - cOutLinkFile, err := os.Open(path.Join(currentDir(), "./test/out/dir/c.txt")) + cOutLinkFile, err := os.Open(filepath.FromSlash(path.Join(currentDir(), "./test/out/dir/c.txt"))) if err != nil { t.Fatal(err) } @@ -112,7 +112,7 @@ func testLink(t *testing.T) { t.Fatal(err) } - cOutFileNew, err := os.Open(path.Join(currentDir(), "./test/out/c.txt")) + cOutFileNew, err := os.Open(filepath.FromSlash(path.Join(currentDir(), "./test/out/c.txt"))) if err != nil { t.Fatal(err) } @@ -124,7 +124,7 @@ func testLink(t *testing.T) { } t.Log("New c.txt content:", string(cOutFileContentNew)) - cOutLinkFileNew, err := os.Open(path.Join(currentDir(), "./test/out/dir/c.txt")) + cOutLinkFileNew, err := os.Open(filepath.FromSlash(path.Join(currentDir(), "./test/out/dir/c.txt"))) if err != nil { t.Fatal(err) } @@ -141,17 +141,17 @@ func testLink(t *testing.T) { } func testSymlink(t *testing.T) { - targetURL, err := filepath.EvalSymlinks(path.Join(currentDir(), "./test/out/d.txt")) + targetURL, err := filepath.EvalSymlinks(filepath.FromSlash(path.Join(currentDir(), "./test/out/d.txt"))) if err != nil { t.Fatal(err) } t.Log("targetURL:", targetURL) - if targetURL != path.Join(currentDir(), "./test/out/dir/d.txt") { + if targetURL != filepath.FromSlash(path.Join(currentDir(), "./test/out/dir/d.txt")) { t.Fatal("Unzip file Symlink error.") } - dOutSymlinkFile, err := os.Open(path.Join(currentDir(), "./test/out/d.txt")) + dOutSymlinkFile, err := os.Open(filepath.FromSlash(path.Join(currentDir(), "./test/out/d.txt"))) if err != nil { t.Fatal(err) } @@ -162,7 +162,7 @@ func testSymlink(t *testing.T) { t.Fatal(err) } - dOutFile, err := os.Open(path.Join(currentDir(), "./test/out/dir/d.txt")) + dOutFile, err := os.Open(filepath.FromSlash(path.Join(currentDir(), "./test/out/dir/d.txt"))) if err != nil { t.Fatal(err) } @@ -179,7 +179,7 @@ func testSymlink(t *testing.T) { } func testLintInDir(t *testing.T) { - eOutFile, err := os.OpenFile(path.Join(currentDir(), "./test/out/dir/dir/e.txt"), os.O_RDWR|os.O_CREATE|os.O_APPEND, 0644) + eOutFile, err := os.OpenFile(filepath.FromSlash(path.Join(currentDir(), "./test/out/dir/dir/e.txt")), os.O_RDWR|os.O_CREATE|os.O_APPEND, 0644) if err != nil { t.Fatal(err) } @@ -190,7 +190,7 @@ func testLintInDir(t *testing.T) { t.Fatal(err) } - eOutLinkFile, err := os.Open(path.Join(currentDir(), "./test/out/dir/e.txt")) + eOutLinkFile, err := os.Open(filepath.FromSlash(path.Join(currentDir(), "./test/out/dir/e.txt"))) if err != nil { t.Fatal(err) } @@ -212,7 +212,7 @@ func testLintInDir(t *testing.T) { t.Fatal(err) } - eOutFileNew, err := os.Open(path.Join(currentDir(), "./test/out/dir/dir/e.txt")) + eOutFileNew, err := os.Open(filepath.FromSlash(path.Join(currentDir(), "./test/out/dir/dir/e.txt"))) if err != nil { t.Fatal(err) } @@ -224,7 +224,7 @@ func testLintInDir(t *testing.T) { } t.Log("New dir/dir/e.txt content:", string(eOutFileContentNew)) - eOutLinkFileNew, err := os.Open(path.Join(currentDir(), "./test/out/dir/e.txt")) + eOutLinkFileNew, err := os.Open(filepath.FromSlash(path.Join(currentDir(), "./test/out/dir/e.txt"))) if err != nil { t.Fatal(err) } @@ -241,17 +241,17 @@ func testLintInDir(t *testing.T) { } func testSymlinkInDir(t *testing.T) { - inDirTargetURL, err := filepath.EvalSymlinks(path.Join(currentDir(), "./test/out/dir/dir/f.txt")) + inDirTargetURL, err := filepath.EvalSymlinks(filepath.FromSlash(path.Join(currentDir(), "./test/out/dir/dir/f.txt"))) if err != nil { t.Fatal(err) } t.Log("F outSymlinkFile link:", inDirTargetURL) - if inDirTargetURL != path.Join(currentDir(), "./test/out/dir/f.txt") { + if inDirTargetURL != filepath.FromSlash(path.Join(currentDir(), "./test/out/dir/f.txt")) { t.Fatal("Unzip file Symlink error.") } - fOutSymlinkFile, err := os.Open(path.Join(currentDir(), "./test/out/dir/dir/f.txt")) + fOutSymlinkFile, err := os.Open(filepath.FromSlash(path.Join(currentDir(), "./test/out/dir/dir/f.txt"))) if err != nil { t.Fatal(err) } @@ -262,7 +262,7 @@ func testSymlinkInDir(t *testing.T) { t.Fatal(err) } - fOutFile, err := os.Open(path.Join(currentDir(), "./test/out/dir/f.txt")) + fOutFile, err := os.Open(filepath.FromSlash(path.Join(currentDir(), "./test/out/dir/f.txt"))) if err != nil { t.Fatal(err) }