@cryptotaxi247 / kubo / commits / 64ccdbd6f

test: use car fixtures in sharness t0113

Laurent Senta committed Feb 15, 2023 at 15:43 UTC 64ccdbd6f26bcd0c24a27d209b662b1fbe80648c
3 files changed +24 -12
test/sharness/t0113-gateway-symlink.sh
+8 -12
@@ -9,26 +9,22 @@ test_description="Test symlink support on the HTTP gateway"
9 test_init_ipfs
10 test_launch_ipfs_daemon
11
12 -
13 -test_expect_success "Create a test directory with symlinks" '
14 - mkdir testfiles &&
15 - echo "content" > testfiles/foo &&
16 - ln -s foo testfiles/bar &&
17 - test_cmp testfiles/foo testfiles/bar
18 -'
19 -
20 -test_expect_success "Add the test directory" '
21 - HASH=$(ipfs add -Qr testfiles)
12 +# Import test case
13 +# See the static fixtures in ./t0113-gateway-symlink/
14 +test_expect_success "Add the test directory with symlinks" '
15 + ipfs dag import ../t0113-gateway-symlink/testfiles.car
16 '
17 +ROOT_DIR_CID=QmWvY6FaqFMS89YAQ9NAPjVP4WZKA1qbHbicc9HeSKQTgt # ./testfiles/
18
19 test_expect_success "Test the directory listing" '
25 - curl "$GWAY_ADDR/ipfs/$HASH/" > list_response &&
20 + curl "$GWAY_ADDR/ipfs/$ROOT_DIR_CID/" > list_response &&
21 test_should_contain ">foo<" list_response &&
22 test_should_contain ">bar<" list_response
23 '
24
25 +# TODO: it's unclear to me if that `echo -n "foo" > expected` should be a fixture somehow.
26 test_expect_success "Test the symlink" '
31 - curl "$GWAY_ADDR/ipfs/$HASH/bar" > bar_actual &&
27 + curl "$GWAY_ADDR/ipfs/$ROOT_DIR_CID/bar" > bar_actual &&
28 echo -n "foo" > bar_expected &&
29 test_cmp bar_expected bar_actual
30 '
test/sharness/t0113-gateway-symlink/README.md new
+16
@@ -0,0 +1,16 @@
1 +# Dataset description/sources
2 +
3 +- testfiles.car
4 + - raw CARv1
5 +
6 +generated with:
7 +
8 +```sh
9 +mkdir testfiles &&
10 +echo "content" > testfiles/foo &&
11 +ln -s foo testfiles/bar &&
12 +ROOT_DIR_CID=$(ipfs add -Qr testfiles) &&
13 +ipfs dag export $ROOT_DIR_CID > testfiles.car
14 +
15 +# ROOT_DIR_CID=QmWvY6FaqFMS89YAQ9NAPjVP4WZKA1qbHbicc9HeSKQTgt
16 +```
test/sharness/t0113-gateway-symlink/testfiles.car
Binary files /dev/null and b/test/sharness/t0113-gateway-symlink/testfiles.car differ