Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
interface-go-dms3-core
Commits
858d49b0
Commit
858d49b0
authored
Jan 05, 2018
by
Łukasz Magiera
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
coreapi: object API tests
License: MIT Signed-off-by:
Łukasz Magiera
<
magik6k@gmail.com
>
parent
104bc87d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
5 deletions
+22
-5
interface.go
interface.go
+13
-5
options/object.go
options/object.go
+9
-0
No files found.
interface.go
View file @
858d49b0
...
...
@@ -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
}
...
...
options/object.go
View file @
858d49b0
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment