test: use car fixtures in sharness t0122
Laurent Senta committed
Feb 20, 2023 at 16:17 UTC
a57ca965c1c6923efb7b11134dc6fc92d10960fa
5 files changed
+45
-14
test/sharness/t0122-gateway-tar.sh
+8
-14
@@ -10,20 +10,14 @@ test_launch_ipfs_daemon_without_network
10
OUTSIDE_ROOT_CID="bafybeicaj7kvxpcv4neaqzwhrqqmdstu4dhrwfpknrgebq6nzcecfucvyu"
11
INSIDE_ROOT_CID="bafybeibfevfxlvxp5vxobr5oapczpf7resxnleb7tkqmdorc4gl5cdva3y"
12
13
+# Import test case
14
+# See the static fixtures in ./t0122-gateway-tar/
15
test_expect_success "Add the test directory" '
14
- mkdir -p rootDir/ipfs &&
15
- mkdir -p rootDir/ipns &&
16
- mkdir -p rootDir/api &&
17
- mkdir -p rootDir/ą/ę &&
18
- echo "I am a txt file on path with utf8" > rootDir/ą/ę/file-źł.txt &&
19
- echo "I am a txt file in confusing /api dir" > rootDir/api/file.txt &&
20
- echo "I am a txt file in confusing /ipfs dir" > rootDir/ipfs/file.txt &&
21
- echo "I am a txt file in confusing /ipns dir" > rootDir/ipns/file.txt &&
22
- DIR_CID=$(ipfs add -Qr --cid-version 1 rootDir) &&
23
- FILE_CID=$(ipfs files stat --enc=json /ipfs/$DIR_CID/ą/ę/file-źł.txt | jq -r .Hash) &&
24
- FILE_SIZE=$(ipfs files stat --enc=json /ipfs/$DIR_CID/ą/ę/file-źł.txt | jq -r .Size)
25
- echo "$FILE_CID / $FILE_SIZE"
16
+ ipfs dag import ../t0122-gateway-tar/fixtures.car
17
'
18
+DIR_CID=bafybeig6ka5mlwkl4subqhaiatalkcleo4jgnr3hqwvpmsqfca27cijp3i # ./rootDir
19
+FILE_CID=bafkreialihlqnf5uwo4byh4n3cmwlntwqzxxs2fg5vanqdi3d7tb2l5xkm # ./rootDir/ą/ę/file-źł.txt
20
+FILE_SIZE=34
21
22
test_expect_success "GET TAR with format=tar and extract" '
23
curl "http://127.0.0.1:$GWAY_PORT/ipfs/$FILE_CID?format=tar" | tar -x
@@ -69,9 +63,9 @@ test_expect_success "GET TAR with explicit ?filename= succeeds with modified Con
63
"
64
65
test_expect_success "Add CARs with relative paths to test with" '
72
- ipfs dag import ../t0122-gateway-tar-data/outside-root.car > import_output &&
66
+ ipfs dag import ../t0122-gateway-tar/outside-root.car > import_output &&
67
test_should_contain $OUTSIDE_ROOT_CID import_output &&
74
- ipfs dag import ../t0122-gateway-tar-data/inside-root.car > import_output &&
68
+ ipfs dag import ../t0122-gateway-tar/inside-root.car > import_output &&
69
test_should_contain $INSIDE_ROOT_CID import_output
70
'
71
test/sharness/t0122-gateway-tar/README.md
new
+37
@@ -0,0 +1,37 @@
1
+# Dataset description/sources
2
+
3
+- inside-root.car
4
+
5
+- outside-root.car
6
+
7
+- fixtures.car
8
+ - raw CARv1
9
+
10
+generated with:
11
+
12
+```sh
13
+# ipfs version 0.18.1
14
+
15
+mkdir -p rootDir/ipfs &&
16
+mkdir -p rootDir/ipns &&
17
+mkdir -p rootDir/api &&
18
+mkdir -p rootDir/ą/ę &&
19
+echo "I am a txt file on path with utf8" > rootDir/ą/ę/file-źł.txt &&
20
+echo "I am a txt file in confusing /api dir" > rootDir/api/file.txt &&
21
+echo "I am a txt file in confusing /ipfs dir" > rootDir/ipfs/file.txt &&
22
+echo "I am a txt file in confusing /ipns dir" > rootDir/ipns/file.txt &&
23
+DIR_CID=$(ipfs add -Qr --cid-version 1 rootDir) &&
24
+FILE_CID=$(ipfs files stat --enc=json /ipfs/$DIR_CID/ą/ę/file-źł.txt | jq -r .Hash) &&
25
+FILE_SIZE=$(ipfs files stat --enc=json /ipfs/$DIR_CID/ą/ę/file-źł.txt | jq -r .Size)
26
+echo "$FILE_CID / $FILE_SIZE"
27
+
28
+echo DIR_CID=${DIR_CID} # ./rootDir
29
+echo FILE_CID=${FILE_CID} # ./rootDir/ą/ę/file-źł.txt
30
+echo FILE_SIZE=${FILE_SIZE}
31
+
32
+ipfs dag export ${DIR_CID} > ./fixtures.car
33
+
34
+# DIR_CID=bafybeig6ka5mlwkl4subqhaiatalkcleo4jgnr3hqwvpmsqfca27cijp3i # ./rootDir
35
+# FILE_CID=bafkreialihlqnf5uwo4byh4n3cmwlntwqzxxs2fg5vanqdi3d7tb2l5xkm # ./rootDir/ą/ę/file-źł.txt
36
+# FILE_SIZE=34
37
+```
test/sharness/t0122-gateway-tar/fixtures.car
Binary files /dev/null and b/test/sharness/t0122-gateway-tar/fixtures.car differ