t0111: use "expr" more to check Location
License: MIT Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Christian Couder committed
Feb 28, 2015 at 08:14 UTC
d9d758cfde1f16279552ae4a518458ad2da9867b
1 file changed
+6
-7
test/sharness/t0111-gateway-writable.sh
+6
-7
@@ -53,21 +53,20 @@ test_expect_success "HTTP PUT file to construct a hierarchy" '
53
echo "PUT http://localhost:5002/ipfs/$HASH_EMPTY_DIR/test.txt" &&
54
curl -svX PUT --data-binary @infile "http://localhost:5002/ipfs/$HASH_EMPTY_DIR/test.txt" 2>curl.out &&
55
grep "HTTP/1.1 201 Created" curl.out &&
56
- grep Location curl.out
56
+ LOCATION=$(grep Location curl.out) &&
57
+ HASH=$(expr "$LOCATION" : "< Location: /ipfs/\(.*\)/test.txt")
58
'
59
60
test_expect_success "We can HTTP GET file just created" '
60
- FILEPATH=$(grep Location curl.out | cut -d" " -f3- | tr -d "\r") &&
61
- echo "$FILEPATH" = "${FILEPATH%/test.txt}/test.txt" &&
62
- [ "$FILEPATH" = "${FILEPATH%/test.txt}/test.txt" ] &&
63
- echo "GET http://localhost:5002$FILEPATH" &&
64
- curl -so outfile http://localhost:5002$FILEPATH &&
61
+ URL="http://localhost:5002/ipfs/$HASH/test.txt" &&
62
+ echo "GET $URL" &&
63
+ curl -so outfile "$URL" &&
64
test_cmp infile outfile
65
'
66
67
test_expect_success "HTTP PUT file to append to existing hierarchy" '
68
echo "$RANDOM" >infile2 &&
70
- URL="http://localhost:5002${FILEPATH%/test.txt}/test/test.txt" &&
69
+ URL="http://localhost:5002/ipfs/$HASH/test/test.txt" &&
70
echo "PUT $URL" &&
71
curl -svX PUT --data-binary @infile2 "$URL" 2>curl.out &&
72
grep "HTTP/1.1 201 Created" curl.out &&