master
sh 53 lines 896 Bytes
Raw
1 #!/usr/bin/env bash
2 #
3 # Copyright (c) 2016 Jeromy Johnson
4 # MIT Licensed; see the LICENSE file in this repository.
5 #
6
7 test_description="test the unix files api flushing"
8
9 . lib/test-lib.sh
10
11 test_init_ipfs
12
13 verify_path_exists() {
14 # simply running ls on a file should be a good 'check'
15 ipfs files ls $1
16 }
17
18 verify_dir_contents() {
19 dir=$1
20 shift
21 rm -f expected
22 touch expected
23 for e in $@
24 do
25 echo $e >> expected
26 done
27
28 test_expect_success "can list dir" '
29 ipfs files ls $dir > output
30 '
31
32 test_expect_success "dir entries look good" '
33 test_sort_cmp output expected
34 '
35 }
36
37 test_launch_ipfs_daemon
38
39 test_expect_success "can copy a file in" '
40 HASH=$(echo "foo" | ipfs add -q) &&
41 ipfs files cp /ipfs/$HASH /file
42 '
43
44 test_kill_ipfs_daemon
45 test_launch_ipfs_daemon
46
47 test_expect_success "file is still there" '
48 verify_path_exists /file
49 '
50
51 test_kill_ipfs_daemon
52
53 test_done