Skip to content

Commit

Permalink
tests: move ENV var save/reset out of testset
Browse files Browse the repository at this point in the history
and bugfix: setting `ENV[var] = nothing` does not delete the var.
  • Loading branch information
StefanKarpinski committed Apr 20, 2021
1 parent db1d8d5 commit 7b774c1
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -403,13 +403,14 @@ include("setup.jl")
end
end

save_env = get(ENV, "JULIA_SSL_NO_VERIFY_HOSTS", nothing)
delete!(ENV, "JULIA_SSL_NO_VERIFY_HOSTS")

@testset "bad TLS" begin
save_env = get(ENV, "JULIA_SSL_NO_VERIFY_HOSTS", nothing)
urls = [
"https://wrong.host.badssl.com"
"https://untrusted-root.badssl.com"
]
ENV["JULIA_SSL_NO_VERIFY_HOSTS"] = nothing
@testset "bad TLS is rejected" for url in urls
resp = request(url, throw=false)
@test resp isa RequestError
Expand Down Expand Up @@ -449,11 +450,13 @@ include("setup.jl")
@test resp isa Response
@test resp.status == 200
end
if save_env !== nothing
ENV["JULIA_SSL_NO_VERIFY_HOSTS"] = save_env
else
delete!(ENV, "JULIA_SSL_NO_VERIFY_HOSTS")
end
delete!(ENV, "JULIA_SSL_NO_VERIFY_HOSTS")
end

if save_env !== nothing
ENV["JULIA_SSL_NO_VERIFY_HOSTS"] = save_env
else
delete!(ENV, "JULIA_SSL_NO_VERIFY_HOSTS")
end

@__MODULE__() == Main && @testset "ftp download" begin
Expand Down

0 comments on commit 7b774c1

Please sign in to comment.