diff --git a/test/sharness/t0123-gateway-json-cbor.sh b/test/sharness/t0123-gateway-json-cbor.sh index 704d075f940a..b22c056de787 100755 --- a/test/sharness/t0123-gateway-json-cbor.sh +++ b/test/sharness/t0123-gateway-json-cbor.sh @@ -7,22 +7,15 @@ test_description="Test HTTP Gateway DAG-JSON (application/vnd.ipld.dag-json) and test_init_ipfs test_launch_ipfs_daemon_without_network +# Import test case +# See the static fixtures in ./t0123-gateway-json-cbor/ test_expect_success "Add the test directory" ' - mkdir -p rootDir/ipfs && - mkdir -p rootDir/ipns && - mkdir -p rootDir/api && - mkdir -p rootDir/ą/ę && - echo "{ \"test\": \"i am a plain json file\" }" > rootDir/ą/ę/t.json && - echo "I am a txt file on path with utf8" > rootDir/ą/ę/file-źł.txt && - echo "I am a txt file in confusing /api dir" > rootDir/api/file.txt && - echo "I am a txt file in confusing /ipfs dir" > rootDir/ipfs/file.txt && - echo "I am a txt file in confusing /ipns dir" > rootDir/ipns/file.txt && - DIR_CID=$(ipfs add -Qr --cid-version 1 rootDir) && - FILE_JSON_CID=$(ipfs files stat --enc=json /ipfs/$DIR_CID/ą/ę/t.json | jq -r .Hash) && - FILE_CID=$(ipfs files stat --enc=json /ipfs/$DIR_CID/ą/ę/file-źł.txt | jq -r .Hash) && - FILE_SIZE=$(ipfs files stat --enc=json /ipfs/$DIR_CID/ą/ę/file-źł.txt | jq -r .Size) - echo "$FILE_CID / $FILE_SIZE" + ipfs dag import ../t0123-gateway-json-cbor/fixtures.car ' +DIR_CID=bafybeiafyvqlazbbbtjnn6how5d6h6l6rxbqc4qgpbmteaiskjrffmyy4a # ./rootDir +FILE_JSON_CID=bafkreibrppizs3g7axs2jdlnjua6vgpmltv7k72l7v7sa6mmht6mne3qqe # ./rootDir/ą/ę/t.json +FILE_CID=bafkreialihlqnf5uwo4byh4n3cmwlntwqzxxs2fg5vanqdi3d7tb2l5xkm # ./rootDir/ą/ę/file-źł.txt +FILE_SIZE=34 ## Quick regression check for JSON stored on UnixFS: ## it has nothing to do with DAG-JSON and JSON codecs, diff --git a/test/sharness/t0123-gateway-json-cbor/README.md b/test/sharness/t0123-gateway-json-cbor/README.md new file mode 100644 index 000000000000..0d9f0e1e1961 --- /dev/null +++ b/test/sharness/t0123-gateway-json-cbor/README.md @@ -0,0 +1,43 @@ +# Dataset description/sources + +- dag-cbor-traversal.car + +- dag-json-traversal.car + +- dag-pb.car + +- dag-pb.json + +- fixtures.car + - raw CARv1 + +generated with: + +```sh +mkdir -p rootDir/ipfs && +mkdir -p rootDir/ipns && +mkdir -p rootDir/api && +mkdir -p rootDir/ą/ę && +echo "{ \"test\": \"i am a plain json file\" }" > rootDir/ą/ę/t.json && +echo "I am a txt file on path with utf8" > rootDir/ą/ę/file-źł.txt && +echo "I am a txt file in confusing /api dir" > rootDir/api/file.txt && +echo "I am a txt file in confusing /ipfs dir" > rootDir/ipfs/file.txt && +echo "I am a txt file in confusing /ipns dir" > rootDir/ipns/file.txt && +DIR_CID=$(ipfs add -Qr --cid-version 1 rootDir) && +FILE_JSON_CID=$(ipfs files stat --enc=json /ipfs/$DIR_CID/ą/ę/t.json | jq -r .Hash) && +FILE_CID=$(ipfs files stat --enc=json /ipfs/$DIR_CID/ą/ę/file-źł.txt | jq -r .Hash) && +FILE_SIZE=$(ipfs files stat --enc=json /ipfs/$DIR_CID/ą/ę/file-źł.txt | jq -r .Size) +echo "$FILE_CID / $FILE_SIZE" + +echo DIR_CID=${DIR_CID} # ./rootDir +echo FILE_JSON_CID=${FILE_JSON_CID} # ./rootDir/ą/ę/t.json +echo FILE_CID=${FILE_CID} # ./rootDir/ą/ę/file-źł.txt +echo FILE_SIZE=${FILE_SIZE} + +ipfs dag export ${DIR_CID} > fixtures.car + +# DIR_CID=bafybeiafyvqlazbbbtjnn6how5d6h6l6rxbqc4qgpbmteaiskjrffmyy4a # ./rootDir +# FILE_JSON_CID=bafkreibrppizs3g7axs2jdlnjua6vgpmltv7k72l7v7sa6mmht6mne3qqe # ./rootDir/ą/ę/t.json +# FILE_CID=bafkreialihlqnf5uwo4byh4n3cmwlntwqzxxs2fg5vanqdi3d7tb2l5xkm # ./rootDir/ą/ę/file-źł.txt +# FILE_SIZE=34 +``` diff --git a/test/sharness/t0123-gateway-json-cbor/fixtures.car b/test/sharness/t0123-gateway-json-cbor/fixtures.car new file mode 100644 index 000000000000..8663730f2fed Binary files /dev/null and b/test/sharness/t0123-gateway-json-cbor/fixtures.car differ