t0111: use "expr" to check Location
This makes it possible to simplify the code. License: MIT Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Christian Couder committed
Feb 28, 2015 at 08:06 UTC
158affac993ed2c6038b65f8d3a57586e4a77415
1 file changed
+8
-7
test/sharness/t0111-gateway-writable.sh
+8
-7
@@ -71,17 +71,18 @@ test_expect_success "HTTP PUT file to append to existing hierarchy" '
71
echo "PUT $URL" &&
72
curl -svX PUT --data-binary @infile2 "$URL" 2>curl.out &&
73
grep "HTTP/1.1 201 Created" curl.out &&
74
- grep Location curl.out
74
+ LOCATION=$(grep Location curl.out) &&
75
+ HASH=$(expr "$LOCATION" : "< Location: /ipfs/\(.*\)/test/test.txt")
76
'
77
78
test_expect_success "We can HTTP GET file just created" '
78
- FILEPATH=$(grep Location curl.out | cut -d" " -f3- | tr -d "\r") &&
79
- [ "$FILEPATH" = "${FILEPATH%/test/test.txt}/test/test.txt" ] &&
80
- echo "GET http://localhost:5002$FILEPATH" &&
81
- curl -so outfile2 "http://localhost:5002$FILEPATH" &&
79
+ URL="http://localhost:5002/ipfs/$HASH/test/test.txt" &&
80
+ echo "GET $URL" &&
81
+ curl -so outfile2 "$URL" &&
82
test_cmp infile2 outfile2 &&
83
- echo "GET http://localhost:5002${FILEPATH%/test/test.txt}/test.txt" &&
84
- curl -so outfile "http://localhost:5002${FILEPATH%/test/test.txt}/test.txt" &&
83
+ URL="http://localhost:5002/ipfs/$HASH/test.txt" &&
84
+ echo "GET $URL" &&
85
+ curl -so outfile "$URL" &&
86
test_cmp infile outfile
87
'
88