mirror of
https://github.com/ipfs/kubo.git
synced 2026-02-27 21:37:57 +08:00
coreapi: use chan for returning results in Unixfs.Ls
License: MIT Signed-off-by: Łukasz Magiera <magik6k@gmail.com> This commit was moved from ipfs/interface-go-ipfs-core@93175e9900 This commit was moved from ipfs/boxo@3afaf889d4
This commit is contained in:
parent
8f0b53d1f7
commit
aeb9cdfae0
@ -754,18 +754,20 @@ func (tp *provider) TestLs(t *testing.T) {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
if len(links) != 1 {
|
||||
t.Fatalf("expected 1 link, got %d", len(links))
|
||||
link := <- links
|
||||
if link.Size != 23 {
|
||||
t.Fatalf("expected size = 23, got %d", link.Size)
|
||||
}
|
||||
if links[0].Size != 23 {
|
||||
t.Fatalf("expected size = 23, got %d", links[0].Size)
|
||||
if link.Name != "name-of-file" {
|
||||
t.Fatalf("expected name = name-of-file, got %s", link.Name)
|
||||
}
|
||||
if links[0].Name != "name-of-file" {
|
||||
t.Fatalf("expected name = name-of-file, got %s", links[0].Name)
|
||||
if link.Cid.String() != "QmX3qQVKxDGz3URVC3861Z3CKtQKGBn6ffXRBBWGMFz9Lr" {
|
||||
t.Fatalf("expected cid = QmX3qQVKxDGz3URVC3861Z3CKtQKGBn6ffXRBBWGMFz9Lr, got %s", link.Cid)
|
||||
}
|
||||
if links[0].Cid.String() != "QmX3qQVKxDGz3URVC3861Z3CKtQKGBn6ffXRBBWGMFz9Lr" {
|
||||
t.Fatalf("expected cid = QmX3qQVKxDGz3URVC3861Z3CKtQKGBn6ffXRBBWGMFz9Lr, got %s", links[0].Cid)
|
||||
if _, ok := <-links; ok {
|
||||
t.Errorf("didn't expect a second link")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func (tp *provider) TestEntriesExpired(t *testing.T) {
|
||||
|
||||
@ -31,5 +31,5 @@ type UnixfsAPI interface {
|
||||
Get(context.Context, Path) (files.Node, error)
|
||||
|
||||
// Ls returns the list of links in a directory
|
||||
Ls(context.Context, Path) ([]*ipld.Link, error)
|
||||
Ls(context.Context, Path) (<-chan *ipld.Link, error)
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user