3 test_description
="Test bundle-uri bundle_uri_parse_line()"
6 TEST_PASSES_SANITIZE_LEAK
=true
9 test_expect_success
'bundle_uri_parse_line() just URIs' '
11 bundle.one.uri=http://example.com/bundle.bdl
12 bundle.two.uri=https://example.com/bundle.bdl
13 bundle.three.uri=file:///usr/share/git/bundle.bdl
16 cat >expect <<-\EOF &&
21 uri = http://example.com/bundle.bdl
23 uri = https://example.com/bundle.bdl
25 uri = file:///usr/share/git/bundle.bdl
28 test-tool bundle-uri parse-key-values in >actual 2>err &&
29 test_must_be_empty err &&
30 test_cmp_config_output expect actual
33 test_expect_success
'bundle_uri_parse_line() parsing edge cases: empty key or value' '
39 cat >err.expect <<-EOF &&
40 error: bundle-uri: line has empty key or value
41 error: bad line: '\''=bogus-value'\''
42 error: bundle-uri: line has empty key or value
43 error: bad line: '\''bogus-key='\''
46 cat >expect <<-\EOF &&
52 test_must_fail test-tool bundle-uri parse-key-values in >actual 2>err &&
53 test_cmp err.expect err &&
54 test_cmp_config_output expect actual
57 test_expect_success
'bundle_uri_parse_line() parsing edge cases: empty lines' '
59 bundle.one.uri=http://example.com/bundle.bdl
61 bundle.two.uri=https://example.com/bundle.bdl
63 bundle.three.uri=file:///usr/share/git/bundle.bdl
66 cat >err.expect <<-\EOF &&
67 error: bundle-uri: got an empty line
68 error: bad line: '\'''\''
69 error: bundle-uri: got an empty line
70 error: bad line: '\'''\''
73 # We fail, but try to continue parsing regardless
74 cat >expect <<-\EOF &&
79 uri = http://example.com/bundle.bdl
81 uri = https://example.com/bundle.bdl
83 uri = file:///usr/share/git/bundle.bdl
86 test_must_fail test-tool bundle-uri parse-key-values in >actual 2>err &&
87 test_cmp err.expect err &&
88 test_cmp_config_output expect actual
91 test_expect_success
'bundle_uri_parse_line() parsing edge cases: duplicate lines' '
93 bundle.one.uri=http://example.com/bundle.bdl
94 bundle.two.uri=https://example.com/bundle.bdl
95 bundle.one.uri=https://example.com/bundle-2.bdl
96 bundle.three.uri=file:///usr/share/git/bundle.bdl
99 cat >err.expect <<-\EOF &&
100 error: bad line: '\''bundle.one.uri=https://example.com/bundle-2.bdl'\''
103 # We fail, but try to continue parsing regardless
104 cat >expect <<-\EOF &&
109 uri = http://example.com/bundle.bdl
111 uri = https://example.com/bundle.bdl
113 uri = file:///usr/share/git/bundle.bdl
116 test_must_fail test-tool bundle-uri parse-key-values in >actual 2>err &&
117 test_cmp err.expect err &&
118 test_cmp_config_output expect actual
121 test_expect_success
'parse config format: just URIs' '
122 cat >expect <<-\EOF &&
127 uri = http://example.com/bundle.bdl
129 uri = https://example.com/bundle.bdl
131 uri = file:///usr/share/git/bundle.bdl
134 test-tool bundle-uri parse-config expect >actual 2>err &&
135 test_must_be_empty err &&
136 test_cmp_config_output expect actual
139 test_expect_success
'parse config format edge cases: empty key or value' '
145 error: bad config line 1 in file in1
148 cat >expect <<-\EOF &&
154 test_must_fail test-tool bundle-uri parse-config in1 >actual 2>err &&
156 test_cmp_config_output expect actual &&
163 error: bad config line 1 in file in2
166 test_must_fail test-tool bundle-uri parse-config in2 >actual 2>err &&
168 test_cmp_config_output expect actual