]> git.ipfire.org Git - thirdparty/git.git/blob - t/t5557-http-get.sh
The third batch
[thirdparty/git.git] / t / t5557-http-get.sh
1 #!/bin/sh
2
3 test_description='test downloading a file by URL'
4
5 TEST_PASSES_SANITIZE_LEAK=true
6
7 . ./test-lib.sh
8
9 . "$TEST_DIRECTORY"/lib-httpd.sh
10 start_httpd
11
12 test_expect_success 'get by URL: 404' '
13 test_when_finished "rm -f file.temp" &&
14 url="$HTTPD_URL/none.txt" &&
15 cat >input <<-EOF &&
16 capabilities
17 get $url file1
18 EOF
19
20 test_must_fail git remote-http $url <input 2>err &&
21 test_path_is_missing file1 &&
22 grep "failed to download file at URL" err
23 '
24
25 test_expect_success 'get by URL: 200' '
26 echo data >"$HTTPD_DOCUMENT_ROOT_PATH/exists.txt" &&
27
28 url="$HTTPD_URL/exists.txt" &&
29 cat >input <<-EOF &&
30 capabilities
31 get $url file2
32
33 EOF
34
35 git remote-http $url <input &&
36 test_cmp "$HTTPD_DOCUMENT_ROOT_PATH/exists.txt" file2
37 '
38
39 test_done