Skip to content

Commit 2e8b5a3

Browse files
committed
added tests for reversibility
I cannot test these-- i dont have docker in osx. I would spend more time but can't. Here's as far as i will get in the near future.
1 parent 6de8f1e commit 2e8b5a3

File tree

2 files changed

+84
-0
lines changed

2 files changed

+84
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/bin/sh
2+
3+
test_description="Migration to many different versions"
4+
5+
. lib/test-lib.sh
6+
7+
test_expect_success "start a docker container" '
8+
DOCID=$(start_docker)
9+
'
10+
11+
test_install_version "v0.4.5"
12+
13+
test_expect_success "'ipfs init' succeeds" '
14+
export IPFS_PATH=/root/.ipfs &&
15+
exec_docker "$DOCID" "IPFS_PATH=$IPFS_PATH BITS=2048 ipfs init" >actual 2>&1 ||
16+
test_fsh cat actual
17+
'
18+
19+
test_expect_success ".ipfs/ has been created" '
20+
exec_docker "$DOCID" "test -d /root/.ipfs && test -f /root/.ipfs/config"
21+
exec_docker "$DOCID" "test -d /root/.ipfs/datastore && test -d /root/.ipfs/blocks"
22+
'
23+
24+
test_install_version "v0.4.0"
25+
test_repo_version "0.4.0"
26+
27+
# ipfs-update should allow migrating back
28+
test_install_version "v0.3.10"
29+
test_repo_version "0.3.10"
30+
31+
test_expect_success "stop docker container" '
32+
stop_docker "$DOCID"
33+
'
34+
35+
test_done
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/bin/sh
2+
3+
test_description="Simple fs-repo-migrations backwards tests"
4+
5+
. lib/test-lib.sh
6+
7+
test_expect_success "start a docker container" '
8+
DOCID=$(start_docker)
9+
'
10+
11+
test_expect_success "fs-repo-migrations binary is on the container" '
12+
exec_docker "$DOCID" "test -f $GUEST_FS_REPO_MIG"
13+
'
14+
15+
test_install_version "v0.4.5"
16+
17+
test_expect_success "'ipfs init' succeeds" '
18+
exec_docker "$DOCID" "IPFS_PATH=/root/.ipfs BITS=2048 ipfs init" >actual 2>&1 ||
19+
test_fsh cat actual
20+
'
21+
22+
test_expect_success ".ipfs/ has been created" '
23+
exec_docker "$DOCID" "test -d /root/.ipfs && test -f /root/.ipfs/config"
24+
exec_docker "$DOCID" "test -d /root/.ipfs/datastore && test -d /root/.ipfs/blocks"
25+
'
26+
27+
test_expect_failure "'fs-repo-migrations -y' fails (no --revert-ok) flag" '
28+
exec_docker "$DOCID" "$GUEST_FS_REPO_MIG -y -to=3" 2>actual
29+
'
30+
31+
test_expect_success "'fs-repo-migrations -y' failure output looks good" '
32+
grep "attempt to run backward migration" actual &&
33+
grep "--revert-ok" actual
34+
'
35+
36+
test_expect_success "'fs-repo-migrations -y --revert-ok' works" '
37+
exec_docker "$DOCID" "$GUEST_FS_REPO_MIG -y -to=3 --revert-ok" >actual
38+
'
39+
40+
test_expect_success "'fs-repo-migrations -y' output looks good" '
41+
grep "Migration 5 to 4 succeeded" actual &&
42+
grep "Migration 4 to 3 succeeded" actual
43+
'
44+
45+
test_expect_success "stop docker container" '
46+
stop_docker "$DOCID"
47+
'
48+
49+
test_done

0 commit comments

Comments
 (0)