Skip to content

Commit 96fc2aa

Browse files
authored
Switch httpbin tests over to JuliaLang-hosted httpbin mock server (#36336)
1 parent d5b47a0 commit 96fc2aa

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

test/download.jl

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# This file is a part of Julia. License is MIT: https://julialang.org/license
22

3-
let urls = ["http://httpbin.org/ip", "https://httpbin.org/ip"]
3+
# Test that `Base.download_url()` is altered by `Base.DOWNLOAD_HOOKS`.
4+
let urls = ["http://httpbin.julialang.org/ip", "https://httpbin.julialang.org/ip"]
45
for url in urls
56
@test Base.download_url(url) == url
67
end
@@ -17,37 +18,39 @@ end
1718
mktempdir() do temp_dir
1819
# Download a file
1920
file = joinpath(temp_dir, "ip")
20-
@test download("http://httpbin.org/ip", file) == file
21+
@test download("https://httpbin.julialang.org/ip", file) == file
2122
@test isfile(file)
2223
@test !isempty(read(file))
2324
ip = read(file, String)
2425

2526
# Test download rewrite hook
2627
push!(Base.DOWNLOAD_HOOKS, url->replace(url, r"/status/404$" => "/ip"))
27-
@test download("http://httpbin.org/status/404", file) == file
28+
@test download("https://httpbin.julialang.org/status/404", file) == file
2829
@test isfile(file)
2930
@test !isempty(read(file))
3031
@test ip == read(file, String)
3132
pop!(Base.DOWNLOAD_HOOKS)
3233

3334
# Download an empty file
3435
empty_file = joinpath(temp_dir, "empty")
35-
@test download("http://httpbin.org/status/200", empty_file) == empty_file
36+
@test download("https://httpbin.julialang.org/status/200", empty_file) == empty_file
3637

3738
# Windows and older versions of curl do not create the empty file (https://github.com/curl/curl/issues/183)
3839
@test !isfile(empty_file) || isempty(read(empty_file))
3940

4041
# Make sure that failed downloads do not leave files around
4142
missing_file = joinpath(temp_dir, "missing")
42-
@test_throws ProcessFailedException download("http://httpbin.org/status/404", missing_file)
43+
@test_throws ProcessFailedException download("https://httpbin.julialang.org/status/404", missing_file)
4344
@test !isfile(missing_file)
4445

45-
# Make sure we properly handle metachar '
46-
metachar_file = joinpath(temp_dir, "metachar")
47-
download("https://httpbin.org/get?test='^'", metachar_file)
48-
metachar_string = read(metachar_file, String)
49-
m = match(r"\"url\"\s*:\s*\"(.*)\"", metachar_string)
50-
@test m.captures[1] == "https://httpbin.org/get?test='^'"
46+
# Make sure we properly handle metachar ' on windows with ^ escaping
47+
if Sys.iswindows()
48+
metachar_file = joinpath(temp_dir, "metachar")
49+
Base.download_powershell("https://httpbin.julialang.org/get?test='^'", metachar_file)
50+
metachar_string = read(metachar_file, String)
51+
m = match(r"\"test\"\s*:\s*\"(.*)\"", metachar_string)
52+
@test m.captures[1] == "'^'"
53+
end
5154

5255
# Use a TEST-NET (192.0.2.0/24) address which shouldn't be bound
5356
invalid_host_file = joinpath(temp_dir, "invalid_host")

0 commit comments

Comments
 (0)