Skip to content

Commit

Permalink
Add sharness tests for mode and mtime
Browse files Browse the repository at this point in the history
  • Loading branch information
gammazero committed Aug 14, 2024
1 parent ad9a7b5 commit 3b27296
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 3 deletions.
6 changes: 3 additions & 3 deletions sharness/t0010-local-node.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ test_expect_success "create a test file" '
cat hash
'
test_expect_success "retrieve a single file" '
ipget --node=local "$(<hash)" &&
ipget --node=local "/ipfs/$(<hash)" &&
test_cmp test_file "$(<hash)"
'

test_expect_success "retrieve a single file with -o" '
ipget -o data.txt --node=local "$(<hash)" &&
ipget -o data.txt --node=local "/ipfs/$(<hash)" &&
test_cmp test_file "data.txt"
'

Expand All @@ -31,7 +31,7 @@ test_expect_success "create a test directory" '
'

test_expect_success "retrieve a directory" '
ipget --node=local -o got_dir "$(<dir_hash)" &&
ipget --node=local -o got_dir "/ipfs/$(<dir_hash)" &&
diff -ru test_dir got_dir
'

Expand Down
41 changes: 41 additions & 0 deletions sharness/t0040-unixfs-mode-modtime.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/bin/env bash

test_description="test the ipget command setting unix mode and modification time"


. lib/test-lib.sh

# start the local ipfs node
test_init_ipfs
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
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" &&
stat -f "%m %p" data.txt > out &&
echo "660000000 100664" > expect &&
test_cmp expect out
'

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
'

test_expect_success "retrieve a directory" '
ipget --node=local -o got_dir "/ipfs/$(<dir_hash)" &&
stat -f "%m %p" got_dir > out2 &&
echo "660000000 40775" > expect2 &&
test_cmp expect2 out2
'

# kill the local ipfs node
test_kill_ipfs_daemon

test_done

0 comments on commit 3b27296

Please sign in to comment.