Skip to content

Commit

Permalink
test: improve names
Browse files Browse the repository at this point in the history
  • Loading branch information
hacdias committed Oct 13, 2022
1 parent 23a4662 commit 7fc6410
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions test/sharness/t0123-gateway-json-cbor.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,53 +23,54 @@ test_expect_success "Add the test directory" '
'

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

test_expect_success "GET $format with format=dag-$format has expected Content-Type" '
test_expect_success "GET $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 $format with 'Accept: application/vnd.ipld.dag-$format' has expected Content-Type" '
test_expect_success "GET $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 $format with format=$format has expected Content-Type" '
test_expect_success "GET $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 $format with 'Accept: application/$format' has expected Content-Type" '
test_expect_success "GET $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 $format has expected output for file" '
test_expect_success "GET $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 $format has expected output for directory" '
test_expect_success "GET $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 $format with format=dag-$format and format=$format produce same output" '
test_expect_success "GET $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 "json"
test_codec "cbor"
test_codec "DAG-JSON" "json"
test_codec "DAG-CBOR" "cbor"

test_kill_ipfs_daemon

Expand Down

0 comments on commit 7fc6410

Please sign in to comment.