-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Do cleanup if there is an error mid-download #68
Changes from 4 commits
b876110
befcefc
8107385
2824e54
3bd73a6
06e9879
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,7 +23,9 @@ withenv("DATADEPS_ALWAYS_ACCEPT"=>"true") do | |
)) | ||
|
||
@test endswith(datadep"Test1", "Test1") || endswith(datadep"Test1", "Test1/") || endswith(datadep"Test1", "Test1\\") | ||
|
||
|
||
@show dummydown | ||
@show dummyhash | ||
@test all_expectations_used(dummyhash) | ||
@test all_expectations_used(dummydown) | ||
|
||
|
@@ -36,4 +38,55 @@ withenv("DATADEPS_ALWAYS_ACCEPT"=>"true") do | |
@test true | ||
end | ||
|
||
|
||
@testset "Ensure when errors occur the datadep will still retrydownloading" begin | ||
@testset "error in checksum" begin | ||
@stub dummydown | ||
@expect dummydown(::Any, ::Any) = joinpath(@__DIR__, "eg.zip") | ||
register(DataDep("TestErrorChecksum", "dummy message", "http://example.void", | ||
(error, "1234"); # this will throw an error | ||
fetch_method=dummydown)) | ||
@test_throws Exception datadep"TestErrorChecksum" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not super important, but you could use an There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point. I remember thinking that. I don't know why I didn't |
||
@test @usecount(dummydown(::Any, ::Any)) == 1 | ||
|
||
@test_throws Exception datadep"TestErrorChecksum" | ||
@test @usecount(dummydown(::Any, ::Any)) == 2 # it should have tried to download again | ||
end | ||
|
||
@testset "error in post fetch" begin | ||
@stub dummydown | ||
@expect dummydown(::Any, ::Any) = joinpath(@__DIR__, "eg.zip") | ||
|
||
register(DataDep("TestErrorPostFetch", "dummy message", "http://example.void", Any, | ||
fetch_method=dummydown, | ||
post_fetch_method = error | ||
)) | ||
@test_throws Exception datadep"TestErrorPostFetch" | ||
@test @usecount(dummydown(::Any, ::Any)) == 1 | ||
|
||
@test_throws Exception datadep"TestErrorPostFetch" | ||
@test @usecount(dummydown(::Any, ::Any)) == 2 # it should have tried to download again | ||
end | ||
|
||
|
||
@testset "error in fetch" begin | ||
use_count = 0 | ||
function error_down(rp,lp) | ||
use_count += 1 | ||
error("no download for you") | ||
end | ||
|
||
register(DataDep("TestErrorFetch", "dummy message", "http://example.void", Any, | ||
fetch_method = error_down | ||
)) | ||
@test_throws Exception datadep"TestErrorFetch" | ||
@test use_count == 1 | ||
|
||
@test_throws Exception datadep"TestErrorFetch" | ||
@test use_count == 2 # it should have tried to download again | ||
end | ||
end | ||
end | ||
|
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these look like leftover debug statements
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed.