mirror of
https://github.com/ipfs/kubo.git
synced 2026-02-21 10:27:46 +08:00
parent
6df76cebe7
commit
334308f532
@ -17,8 +17,10 @@ type BlockRmSettings struct {
|
||||
Force bool
|
||||
}
|
||||
|
||||
type BlockPutOption func(*BlockPutSettings) error
|
||||
type BlockRmOption func(*BlockRmSettings) error
|
||||
type (
|
||||
BlockPutOption func(*BlockPutSettings) error
|
||||
BlockRmOption func(*BlockRmSettings) error
|
||||
)
|
||||
|
||||
func BlockPutOptions(opts ...BlockPutOption) (*BlockPutSettings, error) {
|
||||
var cidPrefix cid.Prefix
|
||||
@ -131,7 +133,6 @@ func (blockOpts) Format(format string) BlockPutOption {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Hash is an option for Block.Put which specifies the multihash settings to use
|
||||
|
||||
@ -8,8 +8,10 @@ type DhtFindProvidersSettings struct {
|
||||
NumProviders int
|
||||
}
|
||||
|
||||
type DhtProvideOption func(*DhtProvideSettings) error
|
||||
type DhtFindProvidersOption func(*DhtFindProvidersSettings) error
|
||||
type (
|
||||
DhtProvideOption func(*DhtProvideSettings) error
|
||||
DhtFindProvidersOption func(*DhtFindProvidersSettings) error
|
||||
)
|
||||
|
||||
func DhtProvideOptions(opts ...DhtProvideOption) (*DhtProvideSettings, error) {
|
||||
options := &DhtProvideSettings{
|
||||
|
||||
@ -16,8 +16,10 @@ type KeyRenameSettings struct {
|
||||
Force bool
|
||||
}
|
||||
|
||||
type KeyGenerateOption func(*KeyGenerateSettings) error
|
||||
type KeyRenameOption func(*KeyRenameSettings) error
|
||||
type (
|
||||
KeyGenerateOption func(*KeyGenerateSettings) error
|
||||
KeyRenameOption func(*KeyRenameSettings) error
|
||||
)
|
||||
|
||||
func KeyGenerateOptions(opts ...KeyGenerateOption) (*KeyGenerateSettings, error) {
|
||||
options := &KeyGenerateSettings{
|
||||
|
||||
@ -24,8 +24,10 @@ type NameResolveSettings struct {
|
||||
ResolveOpts []ropts.ResolveOpt
|
||||
}
|
||||
|
||||
type NamePublishOption func(*NamePublishSettings) error
|
||||
type NameResolveOption func(*NameResolveSettings) error
|
||||
type (
|
||||
NamePublishOption func(*NamePublishSettings) error
|
||||
NameResolveOption func(*NameResolveSettings) error
|
||||
)
|
||||
|
||||
func NamePublishOptions(opts ...NamePublishOption) (*NamePublishSettings, error) {
|
||||
options := &NamePublishSettings{
|
||||
|
||||
@ -14,9 +14,11 @@ type ObjectAddLinkSettings struct {
|
||||
Create bool
|
||||
}
|
||||
|
||||
type ObjectNewOption func(*ObjectNewSettings) error
|
||||
type ObjectPutOption func(*ObjectPutSettings) error
|
||||
type ObjectAddLinkOption func(*ObjectAddLinkSettings) error
|
||||
type (
|
||||
ObjectNewOption func(*ObjectNewSettings) error
|
||||
ObjectPutOption func(*ObjectPutSettings) error
|
||||
ObjectAddLinkOption func(*ObjectAddLinkSettings) error
|
||||
)
|
||||
|
||||
func ObjectNewOptions(opts ...ObjectNewOption) (*ObjectNewSettings, error) {
|
||||
options := &ObjectNewSettings{
|
||||
|
||||
@ -8,8 +8,10 @@ type PubSubSubscribeSettings struct {
|
||||
Discover bool
|
||||
}
|
||||
|
||||
type PubSubPeersOption func(*PubSubPeersSettings) error
|
||||
type PubSubSubscribeOption func(*PubSubSubscribeSettings) error
|
||||
type (
|
||||
PubSubPeersOption func(*PubSubPeersSettings) error
|
||||
PubSubSubscribeOption func(*PubSubSubscribeSettings) error
|
||||
)
|
||||
|
||||
func PubSubPeersOptions(opts ...PubSubPeersOption) (*PubSubPeersSettings, error) {
|
||||
options := &PubSubPeersSettings{
|
||||
|
||||
@ -43,8 +43,10 @@ type UnixfsLsSettings struct {
|
||||
UseCumulativeSize bool
|
||||
}
|
||||
|
||||
type UnixfsAddOption func(*UnixfsAddSettings) error
|
||||
type UnixfsLsOption func(*UnixfsLsSettings) error
|
||||
type (
|
||||
UnixfsAddOption func(*UnixfsAddSettings) error
|
||||
UnixfsLsOption func(*UnixfsLsSettings) error
|
||||
)
|
||||
|
||||
func UnixfsAddOptions(opts ...UnixfsAddOption) (*UnixfsAddSettings, cid.Prefix, error) {
|
||||
options := &UnixfsAddSettings{
|
||||
|
||||
@ -31,15 +31,13 @@ func (tp *TestSuite) TestDag(t *testing.T) {
|
||||
t.Run("TestBatch", tp.TestBatch)
|
||||
}
|
||||
|
||||
var (
|
||||
treeExpected = map[string]struct{}{
|
||||
"a": {},
|
||||
"b": {},
|
||||
"c": {},
|
||||
"c/d": {},
|
||||
"c/e": {},
|
||||
}
|
||||
)
|
||||
var treeExpected = map[string]struct{}{
|
||||
"a": {},
|
||||
"b": {},
|
||||
"c": {},
|
||||
"c/d": {},
|
||||
"c/e": {},
|
||||
}
|
||||
|
||||
func (tp *TestSuite) TestPut(t *testing.T) {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
|
||||
@ -164,4 +164,4 @@ func (tp *TestSuite) TestBasicPublishResolveTimeout(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
//TODO: When swarm api is created, add multinode tests
|
||||
// TODO: When swarm api is created, add multinode tests
|
||||
|
||||
@ -74,7 +74,7 @@ func (tp *TestSuite) TestObjectPut(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
p2, err := api.Object().Put(ctx, strings.NewReader(`{"Data":"YmFy"}`), opt.Object.DataType("base64")) //bar
|
||||
p2, err := api.Object().Put(ctx, strings.NewReader(`{"Data":"YmFy"}`), opt.Object.DataType("base64")) // bar
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@ -53,8 +53,10 @@ func (tp *TestSuite) TestUnixfs(t *testing.T) {
|
||||
}
|
||||
|
||||
// `echo -n 'hello, world!' | ipfs add`
|
||||
var hello = "/ipfs/QmQy2Dw4Wk7rdJKjThjYXzfFJNaRKRHhHP5gHHXroJMYxk"
|
||||
var helloStr = "hello, world!"
|
||||
var (
|
||||
hello = "/ipfs/QmQy2Dw4Wk7rdJKjThjYXzfFJNaRKRHhHP5gHHXroJMYxk"
|
||||
helloStr = "hello, world!"
|
||||
)
|
||||
|
||||
// `echo -n | ipfs add`
|
||||
var emptyFile = "/ipfs/QmbFMke1KXqnYyBBWxB74N4c5SBnJMVAiMNRcGu6x1AwQH"
|
||||
@ -213,7 +215,7 @@ func (tp *TestSuite) TestAdd(t *testing.T) {
|
||||
path: "/ipfs/bafkqaaa",
|
||||
opts: []options.UnixfsAddOption{options.Unixfs.InlineLimit(0), options.Unixfs.Inline(true), options.Unixfs.RawLeaves(true)},
|
||||
},
|
||||
{ //TODO: after coreapi add is used in `ipfs add`, consider making this default for inline
|
||||
{ // TODO: after coreapi add is used in `ipfs add`, consider making this default for inline
|
||||
name: "addInlineRaw",
|
||||
data: strFile(helloStr),
|
||||
path: "/ipfs/bafkqadlimvwgy3zmeb3w64tmmqqq",
|
||||
|
||||
Loading…
Reference in New Issue
Block a user