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