Skip to content

Commit

Permalink
Add tests for buffer size
Browse files Browse the repository at this point in the history
  • Loading branch information
jfunstonRAI committed Dec 12, 2023
1 parent d478c53 commit c26eb3a
Showing 1 changed file with 31 additions and 12 deletions.
43 changes: 31 additions & 12 deletions test/azure_blobs_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,37 @@ Azurite.with(; debug=true, public=false) do conf
@test String(buffer[1:nbytes_read]) == input
end

# If the buffer is too small, we hang
# @testset "100B file, buffer too small" begin
# input = "1,2,3,4,5,6,7,8,9,1\n" ^ 5
# buffer = Vector{UInt8}(undef, 10)
# @assert sizeof(input) == 100
# @assert sizeof(buffer) < sizeof(input)

# nbytes_written = blob_put(joinpath(base_url, "test100B.csv"), codeunits(input), credentials)
# @test nbytes_written == 100

# nbytes_read = blob_get!(joinpath(base_url, "test100B.csv"), buffer, credentials)
# end
@testset "100B file, buffer too small" begin
input = "1,2,3,4,5,6,7,8,9,1\n" ^ 5
buffer = Vector{UInt8}(undef, 10)
@assert sizeof(input) == 100
@assert sizeof(buffer) < sizeof(input)

nbytes_written = blob_put(joinpath(base_url, "test100B.csv"), codeunits(input), credentials)
@test nbytes_written == 100

try
nbytes_read = blob_get!(joinpath(base_url, "test100B.csv"), buffer, credentials)
@test false
catch err
@test err isa ErrorException
end
end

@testset "10B file, exactly sized buffer" begin
input = "0123456789"
buffer = Vector{UInt8}(undef, 10)
@assert sizeof(input) == 10
@assert sizeof(buffer) == sizeof(input)

nbytes_written = blob_put(joinpath(base_url, "testexact.csv"), codeunits(input), credentials)
@test nbytes_written == 10

nbytes_read = blob_get!(joinpath(base_url, "testexact.csv"), buffer, credentials)
@test nbytes_read == 10
@test String(buffer[1:nbytes_read]) == input
end

end # Azurite.with

end # @testitem

0 comments on commit c26eb3a

Please sign in to comment.