Skip to content

Commit

Permalink
Add an integration test demoing streams (#301)
Browse files Browse the repository at this point in the history
Closes #288
  • Loading branch information
timholy authored Mar 3, 2021
1 parent 2e6d961 commit 1d9d382
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"
julia = "0.7, 1"

[extras]
ColorTypes = "3da002f7-5984-5a60-b8a6-cbb66c0b333f"
FilePathsBase = "48062228-2e41-5def-b9a4-89aafe57970f"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["FilePathsBase", "Random", "Test"]
test = ["ColorTypes", "FilePathsBase", "Random", "Test"]
1 change: 1 addition & 0 deletions src/loadsave.jl
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ end

function checkpath_load(file)
file === nothing && return nothing # likely stream io
isa(file, IO) && return nothing
!isfile(file) && throw(ArgumentError("No file exists at given path: $file"))
return nothing
end
Expand Down
18 changes: 18 additions & 0 deletions test/integration.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using FileIO
using ColorTypes
using ColorTypes.FixedPointNumbers
using Pkg
using Test

@testset "Integration" begin
if haskey(ENV, "CI") && Base.VERSION >= v"1.3"
Pkg.add("ImageIO")
img = rand(RGB{N0f8}, 50, 50)
io = IOBuffer()
save(Stream{format"PNG"}(io), img)
buf = take!(io)
io2 = IOBuffer(buf)
img2 = load(io2)
@test img2 == img
end
end
1 change: 1 addition & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ end
include("loadsave.jl")
include("error_handling.jl")
include("test_mimesave.jl")
include("integration.jl")
end

0 comments on commit 1d9d382

Please sign in to comment.