-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathformat_test.go
72 lines (55 loc) · 1.18 KB
/
format_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package format
import (
"errors"
"testing"
cid "github.com/ipfs/go-cid"
mh "github.com/multiformats/go-multihash"
)
type EmptyNode struct{}
var ErrEmptyNode error = errors.New("dummy node")
func (n *EmptyNode) Resolve([]string) (interface{}, []string, error) {
return nil, nil, ErrEmptyNode
}
func (n *EmptyNode) Tree(string, int) []string {
return nil
}
func (n *EmptyNode) ResolveLink([]string) (*Link, []string, error) {
return nil, nil, ErrEmptyNode
}
func (n *EmptyNode) Copy() Node {
return &EmptyNode{}
}
func (n *EmptyNode) Cid() cid.Cid {
id, err := cid.Prefix{
Version: 1,
Codec: cid.Raw,
MhType: mh.IDENTITY,
MhLength: 0,
}.Sum(nil)
if err != nil {
panic("failed to create an empty cid!")
}
return id
}
func (n *EmptyNode) Links() []*Link {
return nil
}
func (n *EmptyNode) Loggable() map[string]interface{} {
return nil
}
func (n *EmptyNode) String() string {
return "[]"
}
func (n *EmptyNode) RawData() []byte {
return nil
}
func (n *EmptyNode) Size() (uint64, error) {
return 0, nil
}
func (n *EmptyNode) Stat() (*NodeStat, error) {
return &NodeStat{}, nil
}
func TestNodeType(t *testing.T) {
// Type assertion.
var _ Node = &EmptyNode{}
}