diff --git a/add.go b/add.go index ad0cedd0b..8de2ea896 100644 --- a/add.go +++ b/add.go @@ -114,7 +114,7 @@ func (s *Shell) AddDir(dir string) (string, error) { Body(reader). Send(context.Background()) if err != nil { - return "", nil + return "", err } defer resp.Close() diff --git a/shell_test.go b/shell_test.go index 91728bb2c..ba0d869de 100644 --- a/shell_test.go +++ b/shell_test.go @@ -126,6 +126,14 @@ func TestAddDir(t *testing.T) { is.Equal(cid, "QmS4ustL54uo8FzR9455qaxZwuMiUhyvMcX9Ba8nUH4uVv") } +func TestAddDirOffline(t *testing.T) { + is := is.New(t) + s := NewShell("0.0.0.0:1234") // connect to an invalid address + + _, err := s.AddDir("./testdata") + is.Err(err) +} + func TestLocalShell(t *testing.T) { is := is.New(t) s := NewLocalShell()