From 16027b00104510eca80f4c0a6023f94643f34e12 Mon Sep 17 00:00:00 2001 From: Nathan Zimmerberg <39104088+nhz2@users.noreply.github.com> Date: Wed, 12 Jul 2023 15:31:25 -0400 Subject: [PATCH] Saving and loading `Vector{UInt8}` Zip Archives (#34) * add new test * fix typo --- test/test_simple-usage.jl | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/test/test_simple-usage.jl b/test/test_simple-usage.jl index 14e7ac5..01f7876 100644 --- a/test/test_simple-usage.jl +++ b/test/test_simple-usage.jl @@ -264,4 +264,36 @@ end "foo" => "bar3", ]) end +end + +@testset "saving and loading an in memory zip file" begin + g = ZGroup() + data1 = rand(10,20) + g["testarray1"] = data1 + attrs(g["testarray1"])["foo"] = "bar1" + data2 = rand(Int,20) + g["testarray2"] = data2 + data3 = rand(UInt8,20) + g["testgroup1"] = ZGroup() + g["testgroup1"]["testarray1"] = data3 + attrs(g["testgroup1/testarray1"])["foo"] = "bar3" + io = IOBuffer() + writer = SmallZarrGroups.ZarrZipWriter(io) + SmallZarrGroups.save_dir(writer, g) + SmallZarrGroups.closewriter(writer) + data = take!(io) + # data now contains the data of a zipfile + # it could be saved to disk, sent to another process, or loaded back as a ZGroup. + gload = SmallZarrGroups.load_dir(SmallZarrGroups.ZarrZipReader(data)) + @test collect(gload["testarray1"]) == data1 + @test attrs(gload["testarray1"]) == OrderedDict([ + "foo" => "bar1", + ]) + @test gload["testarray2"] == data2 + @test attrs(gload["testarray2"]) == OrderedDict([]) + @test attrs(gload) == OrderedDict([]) + @test gload["testgroup1/testarray1"] == data3 + @test attrs(gload["testgroup1/testarray1"]) == OrderedDict([ + "foo" => "bar3", + ]) end \ No newline at end of file