From 7f3c0baa5d009fd1eb6e8ae58ebc4eaef017bca7 Mon Sep 17 00:00:00 2001 From: Laurent Senta Date: Mon, 20 Feb 2023 16:24:57 +0100 Subject: [PATCH] test: use car fixtures in sharness t0123 --- test/sharness/t0123-gateway-json-cbor.sh | 21 +++------ .../t0123-gateway-json-cbor/README.md | 43 ++++++++++++++++++ .../t0123-gateway-json-cbor/fixtures.car | Bin 0 -> 1179 bytes 3 files changed, 50 insertions(+), 14 deletions(-) create mode 100644 test/sharness/t0123-gateway-json-cbor/README.md create mode 100644 test/sharness/t0123-gateway-json-cbor/fixtures.car diff --git a/test/sharness/t0123-gateway-json-cbor.sh b/test/sharness/t0123-gateway-json-cbor.sh index 704d075f9..b22c056de 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 000000000..0d9f0e1e1 --- /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 0000000000000000000000000000000000000000..8663730f2fed608271d33fd2e205c68d544e89b7 GIT binary patch literal 1179 zcmcColvR$Z!{1Tq}`!({@E*_B@ucod~pEh~Fe6+Vnh$AgCCsnVcqC`RsWVjbGnmiQ} za}^R5fSMFQx)n0>6q57v(n^an^U@Xcf#If*l3BzBb|=AbgSzwi)&Fl^GA?Lu%@C?# zekhl4`lzm@t6A&6m@~gjeWiKbkld*ba;G=QorE;ucPA*q5Dq06VNiz(pSd#Sis|Qo z3&&WQwUzSjUDZnWE>nqFajY+Wv%U0UCaex6q=}G2^B@il2gN+Wlmbmr3p)>Tspfra zzuq^&%Z+8;aog1@_L@tNFW#`M%_oCfEfAQZW=d=Wr>M!`oI_B9IV4GOJ6>m-zGd?c z8TsBDGgG&fwdGf4EPLy4gI8MqnXLZyU?E;mqR>6M>u3`=T`36}Kr|XwU!0k9pY`dI z-dtbCS2N$ly#8A6{kLABvd8AnvB?FELTn{^S;hHz5~`pWb_2yQA-m86EKFpafyI_VZ5QMu0#h}}HQ*$!q)^KR00zs~cmMzZ literal 0 HcmV?d00001