Skip to content

Commit 620b52b

Browse files
committed
filestore util: refactor and clean up tests
License: MIT Signed-off-by: Kevin Atkinson <[email protected]>
1 parent 96269e0 commit 620b52b

File tree

1 file changed

+39
-28
lines changed

1 file changed

+39
-28
lines changed

test/sharness/t0271-filestore-utils.sh

Lines changed: 39 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,17 @@ test_description="Test out the filestore nocopy functionality"
88

99
. lib/test-lib.sh
1010

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+
}
1122

1223
test_init_dataset() {
1324
test_expect_success "create a dataset" '
@@ -19,6 +30,11 @@ test_init_dataset() {
1930
'
2031
}
2132

33+
test_init() {
34+
test_init_filestore
35+
test_init_dataset
36+
}
37+
2238
EXPHASH="QmRueCuPMYYvdxWz1vWncF7wzCScEx4qasZXo5aVBb1R4V"
2339

2440
cat <<EOF > ls_expect
@@ -68,11 +84,16 @@ test_filestore_adds() {
6884
'
6985
}
7086

71-
test_filestore_verify() {
87+
# check that the filestore is in a clean state
88+
test_filestore_state() {
7289
test_expect_success "ipfs filestore verify' output looks good'" '
7390
ipfs filestore verify | LC_ALL=C sort > verify_actual
7491
test_cmp verify_expect verify_actual
7592
'
93+
}
94+
95+
test_filestore_verify() {
96+
test_filestore_state
7697

7798
test_expect_success "'ipfs filestore verify HASH' works" '
7899
ipfs filestore verify $FILE1_HASH > verify_actual &&
@@ -113,53 +134,43 @@ test_filestore_verify() {
113134
ipfs filestore verify > verify_actual &&
114135
grep changed verify_actual | grep -q somedir/file3
115136
'
116-
}
117137

118-
cat <<EOF > dups_expect
119-
$FILE1_HASH
120-
EOF
138+
# reset the state for the next test
139+
test_init_dataset
140+
}
121141

122142
test_filestore_dups() {
143+
# make sure the filestore is in a clean state
144+
test_filestore_state
145+
123146
test_expect_success "'ipfs filestore dups'" '
124147
ipfs add --raw-leaves somedir/file1 &&
125148
ipfs filestore dups > dups_actual &&
149+
echo "$FILE1_HASH" > dups_expect
126150
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
139151
'
140152
}
141153

142-
test_init_dataset
154+
#
155+
# No daemon
156+
#
143157

144-
init_ipfs_filestore
158+
test_init
145159

146160
test_filestore_adds
147161

148162
test_filestore_verify
149163

150164
test_filestore_dups
151165

152-
echo "WORKING DIR"
153-
echo "IPFS PATH = " $IPFS_PATH
154-
pwd
155-
156-
157-
test_init_dataset
166+
#
167+
# With daemon
168+
#
158169

159-
init_ipfs_filestore
170+
test_init
160171

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
163174
test_launch_ipfs_daemon --offline
164175

165176
test_filestore_adds

0 commit comments

Comments
 (0)