@cryptotaxi247 / kubo / commits / d13befe9e

add a test for repo verify, and make it return non-zero code on failure

License: MIT Signed-off-by: Jeromy <why@ipfs.io>

Jeromy committed Jul 5, 2016 at 14:58 UTC d13befe9ef7fcdd62b523e7a677bed258121c474
2 files changed +11
core/commands/repo.go
+6
@@ -6,6 +6,7 @@ import (
6 "io"
7 "os"
8 "path/filepath"
9 + "strings"
10
11 bstore "github.com/ipfs/go-ipfs/blocks/blockstore"
12 cmds "github.com/ipfs/go-ipfs/commands"
@@ -263,6 +264,8 @@ var repoVerifyCmd = &cmds.Command{
264 }
265 if fails == 0 {
266 out <- &VerifyProgress{Message: "verify complete, all blocks validated."}
267 + } else {
268 + out <- &VerifyProgress{Message: "verify complete, some blocks were corrupt."}
269 }
270 }()
271
@@ -280,6 +283,9 @@ var repoVerifyCmd = &cmds.Command{
283
284 buf := new(bytes.Buffer)
285 if obj.Message != "" {
286 + if strings.Contains(obj.Message, "blocks were corrupt") {
287 + return nil, fmt.Errorf(obj.Message)
288 + }
289 if len(obj.Message) < 20 {
290 obj.Message += " "
291 }
test/sharness/t0084-repo-read-rehash.sh
+5
@@ -34,4 +34,9 @@ test_expect_success 'getting modified block fails' '
34 grep "block in storage has different hash than requested" err_msg
35 '
36
37 +test_expect_success "block shows up in repo verify" '
38 + test_expect_code 1 ipfs repo verify > verify_out &&
39 + grep "$H_BLOCK2" verify_out
40 +'
41 +
42 test_done