-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1506 from ipfs/feat/patch-create
allow patch to optionally create intermediate dirs
- Loading branch information
Showing
8 changed files
with
488 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package merkledag | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestRemoveLink(t *testing.T) { | ||
nd := &Node{ | ||
Links: []*Link{ | ||
&Link{Name: "a"}, | ||
&Link{Name: "b"}, | ||
&Link{Name: "a"}, | ||
&Link{Name: "a"}, | ||
&Link{Name: "c"}, | ||
&Link{Name: "a"}, | ||
}, | ||
} | ||
|
||
err := nd.RemoveNodeLink("a") | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
if len(nd.Links) != 2 { | ||
t.Fatal("number of links incorrect") | ||
} | ||
|
||
if nd.Links[0].Name != "b" { | ||
t.Fatal("link order wrong") | ||
} | ||
|
||
if nd.Links[1].Name != "c" { | ||
t.Fatal("link order wrong") | ||
} | ||
|
||
// should fail | ||
err = nd.RemoveNodeLink("a") | ||
if err != ErrNotFound { | ||
t.Fatal("should have failed to remove link") | ||
} | ||
|
||
// ensure nothing else got touched | ||
if len(nd.Links) != 2 { | ||
t.Fatal("number of links incorrect") | ||
} | ||
|
||
if nd.Links[0].Name != "b" { | ||
t.Fatal("link order wrong") | ||
} | ||
|
||
if nd.Links[1].Name != "c" { | ||
t.Fatal("link order wrong") | ||
} | ||
} |
Oops, something went wrong.