t0111: use expr again to check location
License: MIT Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Christian Couder committed
Feb 28, 2015 at 18:27 UTC
17ca4f64294c5f0c1f88a82f38b43ad7e0ed9e4d
1 file changed
+7
-4
test/sharness/t0111-gateway-writable.sh
+7
-4
@@ -23,13 +23,16 @@ test_expect_success "HTTP gateway gives access to sample file" '
23
24
test_expect_success "HTTP POST file gives Hash" '
25
echo "$RANDOM" >infile &&
26
- curl -svX POST --data-binary @infile http://localhost:5002/ipfs/ 2>curl.out &&
27
- grep "HTTP/1.1 201 Created" curl.out
26
+ URL="http://localhost:5002/ipfs/" &&
27
+ curl -svX POST --data-binary @infile "$URL" 2>curl.out &&
28
+ grep "HTTP/1.1 201 Created" curl.out &&
29
+ LOCATION=$(grep Location curl.out) &&
30
+ HASH=$(expr "$LOCATION" : "< Location: /ipfs/\(.*\)\s")
31
'
32
33
test_expect_success "We can HTTP GET file just created" '
31
- FILEPATH=$(grep Location curl.out | cut -d" " -f3- | tr -d "\r")
32
- curl -so outfile http://localhost:5002$FILEPATH &&
34
+ URL="http://localhost:5002/ipfs/$HASH" &&
35
+ curl -so outfile "$URL" &&
36
test_cmp infile outfile
37
'
38