mirror of
https://github.com/ipfs/kubo.git
synced 2026-02-27 21:37:57 +08:00
Unixfs.Add nocopy test
License: MIT Signed-off-by: Łukasz Magiera <magik6k@gmail.com> This commit was moved from ipfs/interface-go-ipfs-core@e49c3d2211 This commit was moved from ipfs/boxo@f542e9c788
This commit is contained in:
parent
75fce9a329
commit
a437ea3e4e
@ -101,6 +101,34 @@ func (tp *provider) TestAdd(t *testing.T) {
|
||||
return coreiface.IpfsPath(c)
|
||||
}
|
||||
|
||||
rf, err := ioutil.TempFile(os.TempDir(), "unixfs-add-real")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
rfp := rf.Name()
|
||||
|
||||
if _, err := rf.Write([]byte(helloStr)); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
stat, err := rf.Stat()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if err := rf.Close(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer os.Remove(rfp)
|
||||
|
||||
realFile := func() files.Node {
|
||||
n, err := files.NewReaderPathFile(rfp, ioutil.NopCloser(strings.NewReader(helloStr)), stat)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
cases := []struct {
|
||||
name string
|
||||
data func() files.Node
|
||||
@ -323,6 +351,20 @@ func (tp *provider) TestAdd(t *testing.T) {
|
||||
path: "/ipfs/QmRKGpFfR32FVXdvJiHfo4WJ5TDYBsM1P9raAp1p6APWSp",
|
||||
opts: []options.UnixfsAddOption{options.Unixfs.Hidden(false)},
|
||||
},
|
||||
// NoCopy
|
||||
{
|
||||
name: "simpleNoCopy",
|
||||
data: realFile,
|
||||
path: "/ipfs/zb2rhdhmJjJZs9qkhQCpCQ7VREFkqWw3h1r8utjVvQugwHPFd",
|
||||
opts: []options.UnixfsAddOption{options.Unixfs.Nocopy(true)},
|
||||
},
|
||||
{
|
||||
name: "noCopyNoRaw",
|
||||
data: realFile,
|
||||
path: "/ipfs/zb2rhdhmJjJZs9qkhQCpCQ7VREFkqWw3h1r8utjVvQugwHPFd",
|
||||
opts: []options.UnixfsAddOption{options.Unixfs.Nocopy(true), options.Unixfs.RawLeaves(false)},
|
||||
err: "nocopy option requires '--raw-leaves' to be enabled as well",
|
||||
},
|
||||
// Events / Progress
|
||||
{
|
||||
name: "simpleAddEvent",
|
||||
|
||||
Loading…
Reference in New Issue
Block a user