Skip to content

Commit 5725d20

Browse files
committed
Add test
1 parent f572c6d commit 5725d20

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

os/test/src/ZipOpTests.scala

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,37 @@ object ZipOpTests extends TestSuite {
454454
}
455455
}
456456

457+
test("zipSymlink") - prep { wd =>
458+
val zipFileName = "zipped.zip"
459+
val source = wd / "folder1"
460+
val linkName = "link.txt"
461+
val link = os.rel / linkName
462+
463+
os.symlink(source / link, os.rel / "one.txt")
464+
465+
val zipped = os.zip(
466+
dest = wd / zipFileName,
467+
sources = List(source),
468+
followLinks = false
469+
)
470+
471+
val unzipped = os.unzip(
472+
source = zipped,
473+
dest = wd / "unzipped"
474+
)
475+
476+
import os.{shaded_org_apache_tools_zip => apache}
477+
val zipFile = new apache.ZipFile(zipped.toIO)
478+
val entry = zipFile.getEntry(linkName)
479+
480+
// check if zipped correctly as symlink
481+
assert(
482+
(entry.getUnixMode & apache.PermissionUtils.FILE_TYPE_FLAG) == apache.UnixStat.LINK_FLAG
483+
)
484+
assert(os.isLink(unzipped / link))
485+
assert(os.readLink(unzipped / link) == os.readLink(source / link))
486+
}
487+
457488
test("unzipStream") - prep { wd =>
458489
// Step 1: Create an in-memory ZIP file as a stream
459490
val zipStreamOutput = new ByteArrayOutputStream()

0 commit comments

Comments
 (0)