From e50dfa16603bab618a1836992c858b5b8716a06e Mon Sep 17 00:00:00 2001 From: Stephen Whitmore Date: Fri, 13 May 2016 17:23:24 -0700 Subject: [PATCH] Less aggressive erroring and better tests. License: MIT Signed-off-by: Stephen Whitmore --- mfs/dir.go | 5 +++-- test/sharness/t0250-files-api.sh | 23 +++++++++++++++-------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/mfs/dir.go b/mfs/dir.go index 7793c21d834..79c5b92f789 100644 --- a/mfs/dir.go +++ b/mfs/dir.go @@ -341,7 +341,7 @@ func (d *Directory) AddChild(name string, nd *dag.Node) error { pbn, err := ft.FromBytes(nd.Data) if err != nil { - log.Error("IPNS pointer was not unixfs node") + log.Warning("child was not unixfs node") return err } @@ -356,7 +356,8 @@ func (d *Directory) AddChild(name string, nd *dag.Node) error { } d.files[name] = nfi default: - panic("unrecognized! (NYI)") + log.Error("unrecognized mfs dag node type: ", pbn.GetType()) + return ErrInvalidChild } return nil diff --git a/test/sharness/t0250-files-api.sh b/test/sharness/t0250-files-api.sh index eae1b932d25..ffbb6187a02 100755 --- a/test/sharness/t0250-files-api.sh +++ b/test/sharness/t0250-files-api.sh @@ -409,16 +409,23 @@ test_files_api() { ' # test for https://github.com/ipfs/go-ipfs/issues/2654 - ipfs files mkdir /test_dir - ipfs files rm -r "/test_dir" - echo "content" | ipfs files write -e "/test_file" - ipfs files cp "/test_file" "/test_dir" + test_expect_success "create and remove dir" ' + ipfs files mkdir /test_dir && + ipfs files rm -r "/test_dir" + ' + test_expect_success "create test file" ' + echo "content" | ipfs files write -e "/test_file" + ' + test_expect_success "copy test file onto test dir" ' + ipfs files cp "/test_file" "/test_dir" + ' test_expect_success "test /test_dir" ' - ipfs files stat "/test_dir" - ipfs files read "/test_dir" + ipfs files stat "/test_dir" | grep -q "^Type: file" + ' + test_expect_success "clean up /test_dir and /test_file" ' + ipfs files rm -r /test_dir && + ipfs files rm -r /test_file ' - ipfs files rm -r /test_dir - ipfs files rm -r /test_file } # test offline and online