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

Commit

Permalink
fix: return an error when adding a directory fails
Browse files Browse the repository at this point in the history
fixes #254
  • Loading branch information
Stebalien committed Oct 12, 2021
1 parent 39cfea2 commit aa21eb1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion add.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
8 changes: 8 additions & 0 deletions shell_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit aa21eb1

Please sign in to comment.