Skip to content

Commit

Permalink
fix sharness test
Browse files Browse the repository at this point in the history
  • Loading branch information
gammazero committed Aug 14, 2024
1 parent 4c6ef6d commit 1577c24
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 19 deletions.
2 changes: 0 additions & 2 deletions sharness/dependencies/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ module github.com/ipfs/ipget/sharness/dependencies

go 1.22

toolchain go1.22.5

require (
github.com/chriscool/go-sleep v0.0.0-20150606204034-743ab5f1bb48
github.com/ipfs/ipget v0.9.2
Expand Down
44 changes: 27 additions & 17 deletions sharness/t0040-unixfs-mode-modtime.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,40 +11,50 @@ test_launch_ipfs_daemon

test_expect_success "create test file with mode and mtime" '
echo "hello ipget" > test_file &&
ipfs add -q --mode=0664 --mtime=660000000 test_file > hash
ipfs add -q --mode=0666 --mtime=660000000 test_file > hash
cat hash
'
test_expect_success "retrieve file with mode and mtime" '
ipget -o data.txt --node=local "/ipfs/$(<hash)" &&
test_cmp test_file "data.txt" &&
if test $(uname -s) = "Darwin"; then
stat -f "%m %p" data.txt > out &&
echo "660000000 100664" > expect &&
case $(uname -s) in
Linux|FreeBSD)
stat --format="%Y %a" data.txt > out &&
echo "660000000 666" > expect &&
test_cmp expect out
elif test $(uname -s) = "Linux"; then
stat --format="%a" data.txt > out &&
echo "664" > expect2 &&
;;
Darwin)
stat -f "%m %p" data.txt > out &&
echo "660000000 100666" > expect &&
test_cmp expect out
fi
;;
*)
echo "unsupported system: $(uname)"
esac
'

test_expect_success "create a test directory" '
mkdir test_dir2 &&
cp test_file test_dir2/data.txt &&
ipfs add --mode=0775 --mtime=660000000 -rQ test_dir2 > dir_hash
ipfs add --mode=0777 --mtime=660000000 -rQ test_dir2 > dir_hash
'

test_expect_success "retrieve a directory" '
test_expect_success "retrieve a directory with mode and mtime" '
ipget --node=local -o got_dir "/ipfs/$(<dir_hash)" &&
if test $(uname -s) = "Darwin"; then
stat -f "%m %p" got_dir > out2 &&
echo "660000000 40775" > expect2 &&
case $(uname -s) in
Linux|FreeBSD)
stat --format="%Y %a" got_dir > out2 &&
echo "660000000 777" > expect2 &&
test_cmp expect2 out2
elif test $(uname -s) = "Linux"; then
stat --format="%a" got_dir > out2 &&
echo "775" > expect2 &&
;;
Darwin)
stat -f "%m %p" got_dir > out2 &&
echo "660000000 40777" > expect2 &&
test_cmp expect2 out2
fi
;;
*)
echo "unsupported system: $(uname)"
esac
'

# kill the local ipfs node
Expand Down

0 comments on commit 1577c24

Please sign in to comment.