@cryptotaxi247 / kubo / commits / 620b52b2a

filestore util: refactor and clean up tests

License: MIT Signed-off-by: Kevin Atkinson <k@kevina.org>

Kevin Atkinson committed Feb 13, 2017 at 15:56 UTC 620b52b2aa3e26c1d9d4336fed06098c6c65ce78
1 file changed +39 -28
test/sharness/t0271-filestore-utils.sh
+39 -28
@@ -8,6 +8,17 @@ test_description="Test out the filestore nocopy functionality"
8
9 . lib/test-lib.sh
10
11 +test_init_filestore() {
12 + test_expect_success "clean up old node" '
13 + rm -rf "$IPFS_PATH" mountdir ipfs ipns
14 + '
15 +
16 + test_init_ipfs
17 +
18 + test_expect_success "enable filestore config setting" '
19 + ipfs config --json Experimental.FilestoreEnabled true
20 + '
21 +}
22
23 test_init_dataset() {
24 test_expect_success "create a dataset" '
@@ -19,6 +30,11 @@ test_init_dataset() {
30 '
31 }
32
33 +test_init() {
34 + test_init_filestore
35 + test_init_dataset
36 +}
37 +
38 EXPHASH="QmRueCuPMYYvdxWz1vWncF7wzCScEx4qasZXo5aVBb1R4V"
39
40 cat <<EOF > ls_expect
@@ -68,11 +84,16 @@ test_filestore_adds() {
84 '
85 }
86
71 -test_filestore_verify() {
87 +# check that the filestore is in a clean state
88 +test_filestore_state() {
89 test_expect_success "ipfs filestore verify' output looks good'" '
90 ipfs filestore verify | LC_ALL=C sort > verify_actual
91 test_cmp verify_expect verify_actual
92 '
93 +}
94 +
95 +test_filestore_verify() {
96 + test_filestore_state
97
98 test_expect_success "'ipfs filestore verify HASH' works" '
99 ipfs filestore verify $FILE1_HASH > verify_actual &&
@@ -113,35 +134,28 @@ test_filestore_verify() {
134 ipfs filestore verify > verify_actual &&
135 grep changed verify_actual | grep -q somedir/file3
136 '
116 -}
137
118 -cat <<EOF > dups_expect
119 -$FILE1_HASH
120 -EOF
138 + # reset the state for the next test
139 + test_init_dataset
140 +}
141
142 test_filestore_dups() {
143 + # make sure the filestore is in a clean state
144 + test_filestore_state
145 +
146 test_expect_success "'ipfs filestore dups'" '
147 ipfs add --raw-leaves somedir/file1 &&
148 ipfs filestore dups > dups_actual &&
149 + echo "$FILE1_HASH" > dups_expect
150 test_cmp dups_expect dups_actual
127 -'
128 -}
129 -
130 -init_ipfs_filestore() {
131 - test_expect_success "clean up old node" '
132 - rm -rf "$IPFS_PATH" mountdir ipfs ipns
133 - '
134 -
135 - test_init_ipfs
136 -
137 - test_expect_success "enable filestore config setting" '
138 - ipfs config --json Experimental.FilestoreEnabled true
151 '
152 }
153
142 -test_init_dataset
154 +#
155 +# No daemon
156 +#
157
144 -init_ipfs_filestore
158 +test_init
159
160 test_filestore_adds
161
@@ -149,17 +163,14 @@ test_filestore_verify
163
164 test_filestore_dups
165
152 -echo "WORKING DIR"
153 -echo "IPFS PATH = " $IPFS_PATH
154 -pwd
155 -
156 -
157 -test_init_dataset
166 +#
167 +# With daemon
168 +#
169
159 -init_ipfs_filestore
170 +test_init
171
161 -# must be in offline mode so tests of retrieving non-exist blocks
162 -# don't hang
172 +# must be in offline mode so tests that retrieve non-existent blocks
173 +# doesn't hang
174 test_launch_ipfs_daemon --offline
175
176 test_filestore_adds