Commit 858d49b0 authored by Łukasz Magiera's avatar Łukasz Magiera

coreapi: object API tests

License: MIT
Signed-off-by: default avatarŁukasz Magiera <magik6k@gmail.com>
parent 104bc87d
......@@ -219,6 +219,14 @@ type ObjectAPI interface {
// * "json"
WithInputEnc(e string) options.ObjectPutOption
// WithDataType specifies the encoding of data field when using Josn or XML
// input encoding.
//
// Supported types:
// * "text" (default)
// * "base64"
WithDataType(t string) options.ObjectPutOption
// Get returns the node for the path
Get(context.Context, Path) (Node, error)
......@@ -234,20 +242,20 @@ type ObjectAPI interface {
// AddLink adds a link under the specified path. child path can point to a
// subdirectory within the patent which must be present (can be overridden
// with WithCreate option).
AddLink(ctx context.Context, base Path, name string, child Path, opts ...options.ObjectAddLinkOption) (Node, error)
AddLink(ctx context.Context, base Path, name string, child Path, opts ...options.ObjectAddLinkOption) (Path, error)
// WithCreate is an option for AddLink which specifies whether create required
// directories for the child
WithCreate(create bool) options.ObjectAddLinkOption
// RmLink removes a link from the node
RmLink(ctx context.Context, base Path, link string) (Node, error)
RmLink(ctx context.Context, base Path, link string) (Path, error)
// AppendData appends data to the node
AppendData(context.Context, Path, io.Reader) (Node, error)
AppendData(context.Context, Path, io.Reader) (Path, error)
// SetData sets the data contained in the node
SetData(context.Context, Path, io.Reader) (Node, error)
SetData(context.Context, Path, io.Reader) (Path, error)
}
// ObjectStat provides information about dag nodes
......@@ -267,7 +275,7 @@ type ObjectStat struct {
// DataSize is the size of data block section
DataSize int
// CumulativeSize is size of node
// CumulativeSize is size of the tree (BlockSize + link sizes)
CumulativeSize int
}
......
......@@ -6,6 +6,7 @@ type ObjectNewSettings struct {
type ObjectPutSettings struct {
InputEnc string
DataType string
}
type ObjectAddLinkSettings struct {
......@@ -33,6 +34,7 @@ func ObjectNewOptions(opts ...ObjectNewOption) (*ObjectNewSettings, error) {
func ObjectPutOptions(opts ...ObjectPutOption) (*ObjectPutSettings, error) {
options := &ObjectPutSettings{
InputEnc: "json",
DataType: "text",
}
for _, opt := range opts {
......@@ -74,6 +76,13 @@ func (api *ObjectOptions) WithInputEnc(e string) ObjectPutOption {
}
}
func (api *ObjectOptions) WithDataType(t string) ObjectPutOption {
return func(settings *ObjectPutSettings) error {
settings.DataType = t
return nil
}
}
func (api *ObjectOptions) WithCreate(create bool) ObjectAddLinkOption {
return func(settings *ObjectAddLinkSettings) error {
settings.Create = create
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment