Skip to content
This repository was archived by the owner on Feb 7, 2024. It is now read-only.

Commit 0379ac8

Browse files
authored
Merge pull request #256 from ipfs/fix/add-fail
fix: return an error when adding a directory fails
2 parents 39cfea2 + aa21eb1 commit 0379ac8

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

add.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ func (s *Shell) AddDir(dir string) (string, error) {
114114
Body(reader).
115115
Send(context.Background())
116116
if err != nil {
117-
return "", nil
117+
return "", err
118118
}
119119

120120
defer resp.Close()

shell_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,14 @@ func TestAddDir(t *testing.T) {
126126
is.Equal(cid, "QmS4ustL54uo8FzR9455qaxZwuMiUhyvMcX9Ba8nUH4uVv")
127127
}
128128

129+
func TestAddDirOffline(t *testing.T) {
130+
is := is.New(t)
131+
s := NewShell("0.0.0.0:1234") // connect to an invalid address
132+
133+
_, err := s.AddDir("./testdata")
134+
is.Err(err)
135+
}
136+
129137
func TestLocalShell(t *testing.T) {
130138
is := is.New(t)
131139
s := NewLocalShell()

0 commit comments

Comments
 (0)