Skip to content

Commit

Permalink
tests: rename current tests to indicate they're unixfs only
Browse files Browse the repository at this point in the history
  • Loading branch information
hacdias committed Oct 17, 2022
1 parent 11b7a74 commit 312ef5f
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions test/sharness/t0123-gateway-json-cbor.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,55 +22,55 @@ test_expect_success "Add the test directory" '
echo "$FILE_CID / $FILE_SIZE"
'

test_codec () {
test_codec_unixfs () {
name=$1
format=$2

test_expect_success "GET $name with format=dag-$format has expected Content-Type" '
test_expect_success "GET UnixFS $name with format=dag-$format has expected Content-Type" '
curl -sD - "http://127.0.0.1:$GWAY_PORT/ipfs/$FILE_CID?format=dag-$format" > curl_output 2>&1 &&
test_should_contain "Content-Type: application/vnd.ipld.dag-$format" curl_output &&
test_should_not_contain "Content-Type: application/$format" curl_output
'

test_expect_success "GET $name with 'Accept: application/vnd.ipld.dag-$format' has expected Content-Type" '
test_expect_success "GET UnixFS $name with 'Accept: application/vnd.ipld.dag-$format' has expected Content-Type" '
curl -sD - -H "Accept: application/vnd.ipld.dag-$format" "http://127.0.0.1:$GWAY_PORT/ipfs/$FILE_CID" > curl_output 2>&1 &&
test_should_contain "Content-Type: application/vnd.ipld.dag-$format" curl_output &&
test_should_not_contain "Content-Type: application/$format" curl_output
'

test_expect_success "GET $name with format=$format has expected Content-Type" '
test_expect_success "GET UnixFS $name with format=$format has expected Content-Type" '
curl -sD - "http://127.0.0.1:$GWAY_PORT/ipfs/$FILE_CID?format=$format" > curl_output 2>&1 &&
test_should_contain "Content-Type: application/$format" curl_output &&
test_should_not_contain "Content-Type: application/vnd.ipld.dag-$format" curl_output
'

test_expect_success "GET $name with 'Accept: application/$format' has expected Content-Type" '
test_expect_success "GET UnixFS $name with 'Accept: application/$format' has expected Content-Type" '
curl -sD - -H "Accept: application/$format" "http://127.0.0.1:$GWAY_PORT/ipfs/$FILE_CID" > curl_output 2>&1 &&
test_should_contain "Content-Type: application/$format" curl_output &&
test_should_not_contain "Content-Type: application/vnd.ipld.dag-$format" curl_output
'

test_expect_success "GET $name has expected output for file" '
test_expect_success "GET UnixFS $name has expected output for file" '
curl -s "http://127.0.0.1:$GWAY_PORT/ipfs/$FILE_CID?format=dag-$format" > curl_output 2>&1 &&
ipfs dag get --output-codec dag-$format $FILE_CID > ipfs_dag_get_output 2>&1 &&
test_cmp ipfs_dag_get_output curl_output
'

test_expect_success "GET $name has expected output for directory" '
test_expect_success "GET UnixFS $name has expected output for directory" '
curl -s "http://127.0.0.1:$GWAY_PORT/ipfs/$DIR_CID?format=dag-$format" > curl_output 2>&1 &&
ipfs dag get --output-codec dag-$format $DIR_CID > ipfs_dag_get_output 2>&1 &&
test_cmp ipfs_dag_get_output curl_output
'

test_expect_success "GET $name with format=dag-$format and format=$format produce same output" '
test_expect_success "GET UnixFS $name with format=dag-$format and format=$format produce same output" '
curl -s "http://127.0.0.1:$GWAY_PORT/ipfs/$DIR_CID?format=dag-$format" > curl_output_1 2>&1 &&
curl -s "http://127.0.0.1:$GWAY_PORT/ipfs/$DIR_CID?format=$format" > curl_output_2 2>&1 &&
test_cmp curl_output_1 curl_output_2
'
}

test_codec "DAG-JSON" "json"
test_codec "DAG-CBOR" "cbor"
test_codec_unixfs "DAG-JSON" "json"
test_codec_unixfs "DAG-CBOR" "cbor"

test_kill_ipfs_daemon

Expand Down

0 comments on commit 312ef5f

Please sign in to comment.