test: use car fixtures in sharness t0123
Laurent Senta committed
Feb 20, 2023 at 16:24 UTC
7f3c0baa5d009fd1eb6e8ae58ebc4eaef017bca7
3 files changed
+50
-14
test/sharness/t0123-gateway-json-cbor.sh
+7
-14
@@ -7,22 +7,15 @@ test_description="Test HTTP Gateway DAG-JSON (application/vnd.ipld.dag-json) and
7
test_init_ipfs
8
test_launch_ipfs_daemon_without_network
9
10
+# Import test case
11
+# See the static fixtures in ./t0123-gateway-json-cbor/
12
test_expect_success "Add the test directory" '
11
- mkdir -p rootDir/ipfs &&
12
- mkdir -p rootDir/ipns &&
13
- mkdir -p rootDir/api &&
14
- mkdir -p rootDir/ą/ę &&
15
- echo "{ \"test\": \"i am a plain json file\" }" > rootDir/ą/ę/t.json &&
16
- echo "I am a txt file on path with utf8" > rootDir/ą/ę/file-źł.txt &&
17
- echo "I am a txt file in confusing /api dir" > rootDir/api/file.txt &&
18
- echo "I am a txt file in confusing /ipfs dir" > rootDir/ipfs/file.txt &&
19
- echo "I am a txt file in confusing /ipns dir" > rootDir/ipns/file.txt &&
20
- DIR_CID=$(ipfs add -Qr --cid-version 1 rootDir) &&
21
- FILE_JSON_CID=$(ipfs files stat --enc=json /ipfs/$DIR_CID/ą/ę/t.json | jq -r .Hash) &&
22
- FILE_CID=$(ipfs files stat --enc=json /ipfs/$DIR_CID/ą/ę/file-źł.txt | jq -r .Hash) &&
23
- FILE_SIZE=$(ipfs files stat --enc=json /ipfs/$DIR_CID/ą/ę/file-źł.txt | jq -r .Size)
24
- echo "$FILE_CID / $FILE_SIZE"
13
+ ipfs dag import ../t0123-gateway-json-cbor/fixtures.car
14
'
15
+DIR_CID=bafybeiafyvqlazbbbtjnn6how5d6h6l6rxbqc4qgpbmteaiskjrffmyy4a # ./rootDir
16
+FILE_JSON_CID=bafkreibrppizs3g7axs2jdlnjua6vgpmltv7k72l7v7sa6mmht6mne3qqe # ./rootDir/ą/ę/t.json
17
+FILE_CID=bafkreialihlqnf5uwo4byh4n3cmwlntwqzxxs2fg5vanqdi3d7tb2l5xkm # ./rootDir/ą/ę/file-źł.txt
18
+FILE_SIZE=34
19
20
## Quick regression check for JSON stored on UnixFS:
21
## it has nothing to do with DAG-JSON and JSON codecs,
test/sharness/t0123-gateway-json-cbor/README.md
new
+43
@@ -0,0 +1,43 @@
1
+# Dataset description/sources
2
+
3
+- dag-cbor-traversal.car
4
+
5
+- dag-json-traversal.car
6
+
7
+- dag-pb.car
8
+
9
+- dag-pb.json
10
+
11
+- fixtures.car
12
+ - raw CARv1
13
+
14
+generated with:
15
+
16
+```sh
17
+mkdir -p rootDir/ipfs &&
18
+mkdir -p rootDir/ipns &&
19
+mkdir -p rootDir/api &&
20
+mkdir -p rootDir/ą/ę &&
21
+echo "{ \"test\": \"i am a plain json file\" }" > rootDir/ą/ę/t.json &&
22
+echo "I am a txt file on path with utf8" > rootDir/ą/ę/file-źł.txt &&
23
+echo "I am a txt file in confusing /api dir" > rootDir/api/file.txt &&
24
+echo "I am a txt file in confusing /ipfs dir" > rootDir/ipfs/file.txt &&
25
+echo "I am a txt file in confusing /ipns dir" > rootDir/ipns/file.txt &&
26
+DIR_CID=$(ipfs add -Qr --cid-version 1 rootDir) &&
27
+FILE_JSON_CID=$(ipfs files stat --enc=json /ipfs/$DIR_CID/ą/ę/t.json | jq -r .Hash) &&
28
+FILE_CID=$(ipfs files stat --enc=json /ipfs/$DIR_CID/ą/ę/file-źł.txt | jq -r .Hash) &&
29
+FILE_SIZE=$(ipfs files stat --enc=json /ipfs/$DIR_CID/ą/ę/file-źł.txt | jq -r .Size)
30
+echo "$FILE_CID / $FILE_SIZE"
31
+
32
+echo DIR_CID=${DIR_CID} # ./rootDir
33
+echo FILE_JSON_CID=${FILE_JSON_CID} # ./rootDir/ą/ę/t.json
34
+echo FILE_CID=${FILE_CID} # ./rootDir/ą/ę/file-źł.txt
35
+echo FILE_SIZE=${FILE_SIZE}
36
+
37
+ipfs dag export ${DIR_CID} > fixtures.car
38
+
39
+# DIR_CID=bafybeiafyvqlazbbbtjnn6how5d6h6l6rxbqc4qgpbmteaiskjrffmyy4a # ./rootDir
40
+# FILE_JSON_CID=bafkreibrppizs3g7axs2jdlnjua6vgpmltv7k72l7v7sa6mmht6mne3qqe # ./rootDir/ą/ę/t.json
41
+# FILE_CID=bafkreialihlqnf5uwo4byh4n3cmwlntwqzxxs2fg5vanqdi3d7tb2l5xkm # ./rootDir/ą/ę/file-źł.txt
42
+# FILE_SIZE=34
43
+```
test/sharness/t0123-gateway-json-cbor/fixtures.car
Binary files /dev/null and b/test/sharness/t0123-gateway-json-cbor/fixtures.car differ