@cryptotaxi247 / kubo / commits / 4d5af93f4

vendor in new go-datastore

License: MIT Signed-off-by: Jeromy <jeromyj@gmail.com>

Jeromy committed Jan 2, 2016 at 17:56 UTC 4d5af93f4373a20d7c2197bb2481f3c723ec3e65
108 files changed +146 -2472
Godeps/Godeps.json
+4 -4
@@ -135,6 +135,10 @@
135 "ImportPath": "github.com/huin/goupnp",
136 "Rev": "223008361153d7d434c1f0ac990cd3fcae6931f5"
137 },
138 + {
139 + "ImportPath": "github.com/ipfs/go-datastore",
140 + "Rev": "e63957b6da369d986ef3e7a3f249779ba3f56c7e"
141 + },
142 {
143 "ImportPath": "github.com/jackpal/go-nat-pmp",
144 "Rev": "a45aa3d54aef73b504e15eb71bea0e5565b5e6e1"
@@ -151,10 +155,6 @@
155 "ImportPath": "github.com/jbenet/go-context/io",
156 "Rev": "d14ea06fba99483203c19d92cfcd13ebe73135f4"
157 },
154 - {
155 - "ImportPath": "github.com/jbenet/go-datastore",
156 - "Rev": "19e39c85262aa4c796b26346f3e1937711ffe2bf"
157 - },
158 {
159 "ImportPath": "github.com/jbenet/go-detect-race",
160 "Rev": "3463798d9574bd0b7eca275dccc530804ff5216f"
Godeps/_workspace/src/github.com/ipfs/go-datastore/.travis.yml renamed
Godeps/_workspace/src/github.com/ipfs/go-datastore/Godeps/Godeps.json renamed
Godeps/_workspace/src/github.com/ipfs/go-datastore/Godeps/Readme renamed
Godeps/_workspace/src/github.com/ipfs/go-datastore/LICENSE renamed
Godeps/_workspace/src/github.com/ipfs/go-datastore/Makefile renamed
Godeps/_workspace/src/github.com/ipfs/go-datastore/README.md renamed
Godeps/_workspace/src/github.com/ipfs/go-datastore/basic_ds.go renamed
+1 -1
@@ -4,7 +4,7 @@ import (
4 "io"
5 "log"
6
7 - dsq "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore/query"
7 + dsq "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore/query"
8 )
9
10 // Here are some basic datastore implementations.
Godeps/_workspace/src/github.com/ipfs/go-datastore/batch.go renamed
Godeps/_workspace/src/github.com/ipfs/go-datastore/callback/callback.go renamed
+2 -2
@@ -1,8 +1,8 @@
1 package callback
2
3 import (
4 - ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore"
5 - dsq "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore/query"
4 + ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore"
5 + dsq "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore/query"
6 )
7
8 type Datastore struct {
Godeps/_workspace/src/github.com/ipfs/go-datastore/coalesce/coalesce.go renamed
+2 -2
@@ -4,8 +4,8 @@ import (
4 "io"
5 "sync"
6
7 - ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore"
8 - dsq "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore/query"
7 + ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore"
8 + dsq "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore/query"
9 )
10
11 // parent keys
Godeps/_workspace/src/github.com/ipfs/go-datastore/datastore.go renamed
+1 -1
@@ -3,7 +3,7 @@ package datastore
3 import (
4 "errors"
5
6 - query "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore/query"
6 + query "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore/query"
7 )
8
9 /*
Godeps/_workspace/src/github.com/ipfs/go-datastore/elastigo/datastore.go renamed
+2 -2
@@ -6,8 +6,8 @@ import (
6 "net/url"
7 "strings"
8
9 - ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore"
10 - query "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore/query"
9 + ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore"
10 + query "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore/query"
11
12 "github.com/codahale/blake2"
13 "github.com/mattbaird/elastigo/api"
Godeps/_workspace/src/github.com/ipfs/go-datastore/flatfs/flatfs.go renamed
+2 -2
@@ -13,8 +13,8 @@ import (
13 "strings"
14 "time"
15
16 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore"
17 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore/query"
16 + "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore"
17 + "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore/query"
18 "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-os-rename"
19
20 logging "github.com/ipfs/go-ipfs/vendor/QmQg1J6vikuXF9oDvm4wpdeAUvvkVEKW1EYDw9HhTMnP2b/go-log"
Godeps/_workspace/src/github.com/ipfs/go-datastore/flatfs/sync_std.go renamed
Godeps/_workspace/src/github.com/ipfs/go-datastore/flatfs/sync_windows.go renamed
Godeps/_workspace/src/github.com/ipfs/go-datastore/fs/fs.go renamed
+2 -2
@@ -24,8 +24,8 @@ import (
24 "path/filepath"
25 "strings"
26
27 - ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore"
28 - query "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore/query"
27 + ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore"
28 + query "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore/query"
29 )
30
31 var ObjectKeySuffix = ".dsobject"
Godeps/_workspace/src/github.com/ipfs/go-datastore/key.go renamed
+1 -1
@@ -6,7 +6,7 @@ import (
6
7 "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/satori/go.uuid"
8
9 - dsq "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore/query"
9 + dsq "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore/query"
10 )
11
12 /*
Godeps/_workspace/src/github.com/ipfs/go-datastore/keytransform/doc.go renamed
+2 -2
@@ -7,8 +7,8 @@
7 // its inverse. For example:
8 //
9 // import (
10 -// ktds "github.com/jbenet/go-datastore/keytransform"
11 -// ds "github.com/jbenet/go-datastore"
10 +// ktds "github.com/ipfs/go-datastore/keytransform"
11 +// ds "github.com/ipfs/go-datastore"
12 // )
13 //
14 // func reverseKey(k ds.Key) ds.Key {
Godeps/_workspace/src/github.com/ipfs/go-datastore/keytransform/interface.go renamed
+1 -1
@@ -1,6 +1,6 @@
1 package keytransform
2
3 -import ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore"
3 +import ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore"
4
5 // KeyMapping is a function that maps one key to annother
6 type KeyMapping func(ds.Key) ds.Key
Godeps/_workspace/src/github.com/ipfs/go-datastore/keytransform/keytransform.go renamed
+2 -2
@@ -3,8 +3,8 @@ package keytransform
3 import (
4 "io"
5
6 - ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore"
7 - dsq "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore/query"
6 + ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore"
7 + dsq "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore/query"
8 )
9
10 type Pair struct {
Godeps/_workspace/src/github.com/ipfs/go-datastore/leveldb/datastore.go renamed
+2 -2
@@ -1,8 +1,8 @@
1 package leveldb
2
3 import (
4 - ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore"
5 - dsq "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore/query"
4 + ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore"
5 + dsq "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore/query"
6 "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/goprocess"
7 "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb"
8 "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/opt"
Godeps/_workspace/src/github.com/ipfs/go-datastore/lru/datastore.go renamed
+2 -2
@@ -5,8 +5,8 @@ import (
5
6 lru "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/hashicorp/golang-lru"
7
8 - ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore"
9 - dsq "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore/query"
8 + ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore"
9 + dsq "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore/query"
10 )
11
12 // Datastore uses golang-lru for internal storage.
Godeps/_workspace/src/github.com/ipfs/go-datastore/measure/measure.go renamed
+2 -2
@@ -7,8 +7,8 @@ import (
7 "time"
8
9 "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/codahale/metrics"
10 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore"
11 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore/query"
10 + "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore"
11 + "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore/query"
12 )
13
14 // Histogram measurements exceeding these limits are dropped. TODO
Godeps/_workspace/src/github.com/ipfs/go-datastore/mount/mount.go renamed
+3 -3
@@ -7,9 +7,9 @@ import (
7 "io"
8 "strings"
9
10 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore"
11 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore/keytransform"
12 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore/query"
10 + "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore"
11 + "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore/keytransform"
12 + "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore/query"
13 )
14
15 var (
Godeps/_workspace/src/github.com/ipfs/go-datastore/namespace/doc.go renamed
+2 -2
@@ -6,8 +6,8 @@
6 // import (
7 // "fmt"
8 //
9 -// ds "github.com/jbenet/go-datastore"
10 -// nsds "github.com/jbenet/go-datastore/namespace"
9 +// ds "github.com/ipfs/go-datastore"
10 +// nsds "github.com/ipfs/go-datastore/namespace"
11 // )
12 //
13 // func main() {
Godeps/_workspace/src/github.com/ipfs/go-datastore/namespace/namespace.go renamed
+3 -3
@@ -4,9 +4,9 @@ import (
4 "fmt"
5 "strings"
6
7 - ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore"
8 - ktds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore/keytransform"
9 - dsq "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore/query"
7 + ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore"
8 + ktds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore/keytransform"
9 + dsq "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore/query"
10 )
11
12 // PrefixTransform constructs a KeyTransform with a pair of functions that
Godeps/_workspace/src/github.com/ipfs/go-datastore/panic/panic.go renamed
+2 -2
@@ -5,8 +5,8 @@ import (
5 "io"
6 "os"
7
8 - ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore"
9 - dsq "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore/query"
8 + ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore"
9 + dsq "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore/query"
10 )
11
12 type datastore struct {
Godeps/_workspace/src/github.com/ipfs/go-datastore/query/filter.go renamed
Godeps/_workspace/src/github.com/ipfs/go-datastore/query/order.go renamed
Godeps/_workspace/src/github.com/ipfs/go-datastore/query/query.go renamed
Godeps/_workspace/src/github.com/ipfs/go-datastore/query/query_impl.go renamed
Godeps/_workspace/src/github.com/ipfs/go-datastore/redis/redis.go renamed
+2 -2
@@ -7,8 +7,8 @@ import (
7 "time"
8
9 "github.com/fzzy/radix/redis"
10 - datastore "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore"
11 - query "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore/query"
10 + datastore "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore"
11 + query "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore/query"
12 )
13
14 var _ datastore.Datastore = &Datastore{}
Godeps/_workspace/src/github.com/ipfs/go-datastore/sync/sync.go renamed
+10 -9
@@ -4,8 +4,8 @@ import (
4 "io"
5 "sync"
6
7 - ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore"
8 - dsq "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore/query"
7 + ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore"
8 + dsq "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore/query"
9 )
10
11 // MutexDatastore contains a child datastire and a mutex.
@@ -79,6 +79,7 @@ func (d *MutexDatastore) Batch() (ds.Batch, error) {
79 }
80 return &syncBatch{
81 batch: b,
82 + mds: d,
83 }, nil
84 }
85
@@ -92,24 +93,24 @@ func (d *MutexDatastore) Close() error {
93 }
94
95 type syncBatch struct {
95 - lk sync.Mutex
96 batch ds.Batch
97 + mds *MutexDatastore
98 }
99
100 func (b *syncBatch) Put(key ds.Key, val interface{}) error {
100 - b.lk.Lock()
101 - defer b.lk.Unlock()
101 + b.mds.Lock()
102 + defer b.mds.Unlock()
103 return b.batch.Put(key, val)
104 }
105
106 func (b *syncBatch) Delete(key ds.Key) error {
106 - b.lk.Lock()
107 - defer b.lk.Unlock()
107 + b.mds.Lock()
108 + defer b.mds.Unlock()
109 return b.batch.Delete(key)
110 }
111
112 func (b *syncBatch) Commit() error {
112 - b.lk.Lock()
113 - defer b.lk.Unlock()
113 + b.mds.Lock()
114 + defer b.mds.Unlock()
115 return b.batch.Commit()
116 }
Godeps/_workspace/src/github.com/ipfs/go-datastore/syncmount/mount.go renamed
+3 -3
@@ -8,9 +8,9 @@ import (
8 "strings"
9 "sync"
10
11 - ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore"
12 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore/keytransform"
13 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore/query"
11 + ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore"
12 + "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore/keytransform"
13 + "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore/query"
14 )
15
16 var (
Godeps/_workspace/src/github.com/ipfs/go-datastore/test/assert.go renamed
Godeps/_workspace/src/github.com/ipfs/go-datastore/test/test_util.go renamed
+1 -1
@@ -6,7 +6,7 @@ import (
6 "testing"
7
8 rand "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/dustin/randbo"
9 - dstore "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore"
9 + dstore "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore"
10 )
11
12 func RunBatchTest(t *testing.T, ds dstore.Batching) {
Godeps/_workspace/src/github.com/ipfs/go-datastore/tiered/tiered.go renamed
+2 -2
@@ -4,8 +4,8 @@ import (
4 "fmt"
5 "sync"
6
7 - ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore"
8 - dsq "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore/query"
7 + ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore"
8 + dsq "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore/query"
9 )
10
11 type tiered []ds.Datastore
Godeps/_workspace/src/github.com/ipfs/go-datastore/timecache/timecache.go renamed
+2 -2
@@ -5,8 +5,8 @@ import (
5 "sync"
6 "time"
7
8 - ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore"
9 - dsq "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore/query"
8 + ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore"
9 + dsq "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore/query"
10 )
11
12 // op keys
Godeps/_workspace/src/github.com/jbenet/go-datastore/coalesce/coalesce_test.go deleted
-299
@@ -1,299 +0,0 @@
1 -package coalesce
2 -
3 -import (
4 - "fmt"
5 - "sync"
6 - "testing"
7 - "time"
8 -
9 - ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore"
10 - dscb "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore/callback"
11 - dssync "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore/sync"
12 -)
13 -
14 -type mock struct {
15 - sync.Mutex
16 -
17 - inside int
18 - outside int
19 - ds ds.Datastore
20 -}
21 -
22 -func setup() *mock {
23 - m := &mock{}
24 -
25 - mp := ds.NewMapDatastore()
26 - ts := dssync.MutexWrap(mp)
27 - cb1 := dscb.Wrap(ts, func() {
28 - m.Lock()
29 - m.inside++
30 - m.Unlock()
31 - <-time.After(20 * time.Millisecond)
32 - })
33 - cd := Wrap(cb1)
34 - cb2 := dscb.Wrap(cd, func() {
35 - m.Lock()
36 - m.outside++
37 - m.Unlock()
38 - })
39 -
40 - m.ds = cb2
41 - return m
42 -}
43 -
44 -func TestCoalesceSamePut(t *testing.T) {
45 - m := setup()
46 - done := make(chan struct{})
47 -
48 - go func() {
49 - m.ds.Put(ds.NewKey("foo"), "bar")
50 - done <- struct{}{}
51 - }()
52 - go func() {
53 - m.ds.Put(ds.NewKey("foo"), "bar")
54 - done <- struct{}{}
55 - }()
56 - go func() {
57 - m.ds.Put(ds.NewKey("foo"), "bar")
58 - done <- struct{}{}
59 - }()
60 -
61 - <-done
62 - <-done
63 - <-done
64 -
65 - if m.inside != 1 {
66 - t.Error("incalls should be 1", m.inside)
67 - }
68 -
69 - if m.outside != 3 {
70 - t.Error("outcalls should be 3", m.outside)
71 - }
72 -}
73 -
74 -func TestCoalesceSamePutDiffPut(t *testing.T) {
75 - m := setup()
76 - done := make(chan struct{})
77 -
78 - go func() {
79 - m.ds.Put(ds.NewKey("foo"), "bar")
80 - done <- struct{}{}
81 - }()
82 - go func() {
83 - m.ds.Put(ds.NewKey("foo"), "bar")
84 - done <- struct{}{}
85 - }()
86 - go func() {
87 - m.ds.Put(ds.NewKey("foo"), "bar2")
88 - done <- struct{}{}
89 - }()
90 - go func() {
91 - m.ds.Put(ds.NewKey("foo"), "bar3")
92 - done <- struct{}{}
93 - }()
94 -
95 - <-done
96 - <-done
97 - <-done
98 - <-done
99 -
100 - if m.inside != 3 {
101 - t.Error("incalls should be 3", m.inside)
102 - }
103 -
104 - if m.outside != 4 {
105 - t.Error("outcalls should be 4", m.outside)
106 - }
107 -}
108 -
109 -func TestCoalesceSameGet(t *testing.T) {
110 - m := setup()
111 - done := make(chan struct{})
112 - errs := make(chan error, 30)
113 -
114 - m.ds.Put(ds.NewKey("foo1"), "bar")
115 - m.ds.Put(ds.NewKey("foo2"), "baz")
116 -
117 - for i := 0; i < 10; i++ {
118 - go func() {
119 - v, err := m.ds.Get(ds.NewKey("foo1"))
120 - if err != nil {
121 - errs <- err
122 - }
123 - if v != "bar" {
124 - errs <- fmt.Errorf("v is not bar", v)
125 - }
126 - done <- struct{}{}
127 - }()
128 - }
129 - for i := 0; i < 10; i++ {
130 - go func() {
131 - v, err := m.ds.Get(ds.NewKey("foo2"))
132 - if err != nil {
133 - errs <- err
134 - }
135 - if v != "baz" {
136 - errs <- fmt.Errorf("v is not baz", v)
137 - }
138 - done <- struct{}{}
139 - }()
140 - }
141 - for i := 0; i < 10; i++ {
142 - go func() {
143 - _, err := m.ds.Get(ds.NewKey("foo3"))
144 - if err == nil {
145 - errs <- fmt.Errorf("no error")
146 - }
147 - done <- struct{}{}
148 - }()
149 - }
150 -
151 - for i := 0; i < 30; i++ {
152 - <-done
153 - }
154 -
155 - if m.inside != 5 {
156 - t.Error("incalls should be 3", m.inside)
157 - }
158 -
159 - if m.outside != 32 {
160 - t.Error("outcalls should be 30", m.outside)
161 - }
162 -}
163 -
164 -func TestCoalesceHas(t *testing.T) {
165 - m := setup()
166 - done := make(chan struct{})
167 - errs := make(chan error, 30)
168 -
169 - m.ds.Put(ds.NewKey("foo1"), "bar")
170 - m.ds.Put(ds.NewKey("foo2"), "baz")
171 -
172 - for i := 0; i < 10; i++ {
173 - go func() {
174 - v, err := m.ds.Has(ds.NewKey("foo1"))
175 - if err != nil {
176 - errs <- err
177 - }
178 - if !v {
179 - errs <- fmt.Errorf("should have foo1")
180 - }
181 - done <- struct{}{}
182 - }()
183 - }
184 - for i := 0; i < 10; i++ {
185 - go func() {
186 - v, err := m.ds.Has(ds.NewKey("foo2"))
187 - if err != nil {
188 - errs <- err
189 - }
190 - if !v {
191 - errs <- fmt.Errorf("should have foo2")
192 - }
193 - done <- struct{}{}
194 - }()
195 - }
196 - for i := 0; i < 10; i++ {
197 - go func() {
198 - v, err := m.ds.Has(ds.NewKey("foo3"))
199 - if err != nil {
200 - errs <- err
201 - }
202 - if v {
203 - errs <- fmt.Errorf("should not have foo3")
204 - }
205 - done <- struct{}{}
206 - }()
207 - }
208 -
209 - for i := 0; i < 30; i++ {
210 - <-done
211 - }
212 -
213 - if m.inside != 5 {
214 - t.Error("incalls should be 3", m.inside)
215 - }
216 -
217 - if m.outside != 32 {
218 - t.Error("outcalls should be 30", m.outside)
219 - }
220 -}
221 -
222 -func TestCoalesceDelete(t *testing.T) {
223 - m := setup()
224 - done := make(chan struct{})
225 - errs := make(chan error, 30)
226 -
227 - m.ds.Put(ds.NewKey("foo1"), "bar1")
228 - m.ds.Put(ds.NewKey("foo2"), "bar2")
229 - m.ds.Put(ds.NewKey("foo3"), "bar3")
230 -
231 - for i := 0; i < 10; i++ {
232 - go func() {
233 - err := m.ds.Delete(ds.NewKey("foo1"))
234 - if err != nil {
235 - errs <- err
236 - }
237 - has, err := m.ds.Has(ds.NewKey("foo1"))
238 - if err != nil {
239 - errs <- err
240 - }
241 - if has {
242 - t.Error("still have it after deleting")
243 - }
244 - done <- struct{}{}
245 - }()
246 - }
247 - for i := 0; i < 10; i++ {
248 - go func() {
249 - err := m.ds.Delete(ds.NewKey("foo2"))
250 - if err != nil {
251 - errs <- err
252 - }
253 - has, err := m.ds.Has(ds.NewKey("foo2"))
254 - if err != nil {
255 - errs <- err
256 - }
257 - if has {
258 - t.Error("still have it after deleting")
259 - }
260 - done <- struct{}{}
261 - }()
262 - }
263 - for i := 0; i < 10; i++ {
264 - go func() {
265 - has, err := m.ds.Has(ds.NewKey("foo3"))
266 - if err != nil {
267 - errs <- err
268 - }
269 - if !has {
270 - t.Error("should still have foo3")
271 - }
272 - done <- struct{}{}
273 - }()
274 - }
275 - for i := 0; i < 10; i++ {
276 - go func() {
277 - has, err := m.ds.Has(ds.NewKey("foo4"))
278 - if err != nil {
279 - errs <- err
280 - }
281 - if has {
282 - t.Error("should not have foo4")
283 - }
284 - done <- struct{}{}
285 - }()
286 - }
287 -
288 - for i := 0; i < 40; i++ {
289 - <-done
290 - }
291 -
292 - if m.inside != 9 {
293 - t.Error("incalls should be 9", m.inside)
294 - }
295 -
296 - if m.outside != 63 {
297 - t.Error("outcalls should be 63", m.outside)
298 - }
299 -}
Godeps/_workspace/src/github.com/jbenet/go-datastore/flatfs/flatfs_test.go deleted
-417
@@ -1,417 +0,0 @@
1 -package flatfs_test
2 -
3 -import (
4 - "encoding/base32"
5 - "io/ioutil"
6 - "os"
7 - "path/filepath"
8 - "runtime"
9 - "testing"
10 -
11 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore"
12 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore/flatfs"
13 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore/query"
14 - dstest "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore/test"
15 -
16 - rand "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/dustin/randbo"
17 -)
18 -
19 -func tempdir(t testing.TB) (path string, cleanup func()) {
20 - path, err := ioutil.TempDir("", "test-datastore-flatfs-")
21 - if err != nil {
22 - t.Fatalf("cannot create temp directory: %v", err)
23 - }
24 -
25 - cleanup = func() {
26 - if err := os.RemoveAll(path); err != nil {
27 - t.Errorf("tempdir cleanup failed: %v", err)
28 - }
29 - }
30 - return path, cleanup
31 -}
32 -
33 -func TestBadPrefixLen(t *testing.T) {
34 - temp, cleanup := tempdir(t)
35 - defer cleanup()
36 -
37 - for i := 0; i > -3; i-- {
38 - _, err := flatfs.New(temp, i, false)
39 - if g, e := err, flatfs.ErrBadPrefixLen; g != e {
40 - t.Errorf("expected ErrBadPrefixLen, got: %v", g)
41 - }
42 - }
43 -}
44 -
45 -func TestPutBadValueType(t *testing.T) {
46 - temp, cleanup := tempdir(t)
47 - defer cleanup()
48 -
49 - fs, err := flatfs.New(temp, 2, false)
50 - if err != nil {
51 - t.Fatalf("New fail: %v\n", err)
52 - }
53 -
54 - err = fs.Put(datastore.NewKey("quux"), 22)
55 - if g, e := err, datastore.ErrInvalidType; g != e {
56 - t.Fatalf("expected ErrInvalidType, got: %v\n", g)
57 - }
58 -}
59 -
60 -func TestPut(t *testing.T) {
61 - temp, cleanup := tempdir(t)
62 - defer cleanup()
63 -
64 - fs, err := flatfs.New(temp, 2, false)
65 - if err != nil {
66 - t.Fatalf("New fail: %v\n", err)
67 - }
68 -
69 - err = fs.Put(datastore.NewKey("quux"), []byte("foobar"))
70 - if err != nil {
71 - t.Fatalf("Put fail: %v\n", err)
72 - }
73 -}
74 -
75 -func TestGet(t *testing.T) {
76 - temp, cleanup := tempdir(t)
77 - defer cleanup()
78 -
79 - fs, err := flatfs.New(temp, 2, false)
80 - if err != nil {
81 - t.Fatalf("New fail: %v\n", err)
82 - }
83 -
84 - const input = "foobar"
85 - err = fs.Put(datastore.NewKey("quux"), []byte(input))
86 - if err != nil {
87 - t.Fatalf("Put fail: %v\n", err)
88 - }
89 -
90 - data, err := fs.Get(datastore.NewKey("quux"))
91 - if err != nil {
92 - t.Fatalf("Get failed: %v", err)
93 - }
94 - buf, ok := data.([]byte)
95 - if !ok {
96 - t.Fatalf("expected []byte from Get, got %T: %v", data, data)
97 - }
98 - if g, e := string(buf), input; g != e {
99 - t.Fatalf("Get gave wrong content: %q != %q", g, e)
100 - }
101 -}
102 -
103 -func TestPutOverwrite(t *testing.T) {
104 - temp, cleanup := tempdir(t)
105 - defer cleanup()
106 -
107 - fs, err := flatfs.New(temp, 2, false)
108 - if err != nil {
109 - t.Fatalf("New fail: %v\n", err)
110 - }
111 -
112 - const (
113 - loser = "foobar"
114 - winner = "xyzzy"
115 - )
116 - err = fs.Put(datastore.NewKey("quux"), []byte(loser))
117 - if err != nil {
118 - t.Fatalf("Put fail: %v\n", err)
119 - }
120 -
121 - err = fs.Put(datastore.NewKey("quux"), []byte(winner))
122 - if err != nil {
123 - t.Fatalf("Put fail: %v\n", err)
124 - }
125 -
126 - data, err := fs.Get(datastore.NewKey("quux"))
127 - if err != nil {
128 - t.Fatalf("Get failed: %v", err)
129 - }
130 - if g, e := string(data.([]byte)), winner; g != e {
131 - t.Fatalf("Get gave wrong content: %q != %q", g, e)
132 - }
133 -}
134 -
135 -func TestGetNotFoundError(t *testing.T) {
136 - temp, cleanup := tempdir(t)
137 - defer cleanup()
138 -
139 - fs, err := flatfs.New(temp, 2, false)
140 - if err != nil {
141 - t.Fatalf("New fail: %v\n", err)
142 - }
143 -
144 - _, err = fs.Get(datastore.NewKey("quux"))
145 - if g, e := err, datastore.ErrNotFound; g != e {
146 - t.Fatalf("expected ErrNotFound, got: %v\n", g)
147 - }
148 -}
149 -
150 -func TestStorage(t *testing.T) {
151 - temp, cleanup := tempdir(t)
152 - defer cleanup()
153 -
154 - const prefixLen = 2
155 - const prefix = "7175"
156 - const target = prefix + string(os.PathSeparator) + "71757578.data"
157 - fs, err := flatfs.New(temp, prefixLen, false)
158 - if err != nil {
159 - t.Fatalf("New fail: %v\n", err)
160 - }
161 -
162 - err = fs.Put(datastore.NewKey("quux"), []byte("foobar"))
163 - if err != nil {
164 - t.Fatalf("Put fail: %v\n", err)
165 - }
166 -
167 - seen := false
168 - walk := func(absPath string, fi os.FileInfo, err error) error {
169 - if err != nil {
170 - return err
171 - }
172 - path, err := filepath.Rel(temp, absPath)
173 - if err != nil {
174 - return err
175 - }
176 - switch path {
177 - case ".", "..":
178 - // ignore
179 - case prefix:
180 - if !fi.IsDir() {
181 - t.Errorf("prefix directory is not a file? %v", fi.Mode())
182 - }
183 - // we know it's there if we see the file, nothing more to
184 - // do here
185 - case target:
186 - seen = true
187 - if !fi.Mode().IsRegular() {
188 - t.Errorf("expected a regular file, mode: %04o", fi.Mode())
189 - }
190 - if runtime.GOOS != "windows" {
191 - if g, e := fi.Mode()&os.ModePerm&0007, os.FileMode(0000); g != e {
192 - t.Errorf("file should not be world accessible: %04o", fi.Mode())
193 - }
194 - }
195 - default:
196 - t.Errorf("saw unexpected directory entry: %q %v", path, fi.Mode())
197 - }
198 - return nil
199 - }
200 - if err := filepath.Walk(temp, walk); err != nil {
201 - t.Fatal("walk: %v", err)
202 - }
203 - if !seen {
204 - t.Error("did not see the data file")
205 - }
206 -}
207 -
208 -func TestHasNotFound(t *testing.T) {
209 - temp, cleanup := tempdir(t)
210 - defer cleanup()
211 -
212 - fs, err := flatfs.New(temp, 2, false)
213 - if err != nil {
214 - t.Fatalf("New fail: %v\n", err)
215 - }
216 -
217 - found, err := fs.Has(datastore.NewKey("quux"))
218 - if err != nil {
219 - t.Fatalf("Has fail: %v\n", err)
220 - }
221 - if g, e := found, false; g != e {
222 - t.Fatalf("wrong Has: %v != %v", g, e)
223 - }
224 -}
225 -
226 -func TestHasFound(t *testing.T) {
227 - temp, cleanup := tempdir(t)
228 - defer cleanup()
229 -
230 - fs, err := flatfs.New(temp, 2, false)
231 - if err != nil {
232 - t.Fatalf("New fail: %v\n", err)
233 - }
234 - err = fs.Put(datastore.NewKey("quux"), []byte("foobar"))
235 - if err != nil {
236 - t.Fatalf("Put fail: %v\n", err)
237 - }
238 -
239 - found, err := fs.Has(datastore.NewKey("quux"))
240 - if err != nil {
241 - t.Fatalf("Has fail: %v\n", err)
242 - }
243 - if g, e := found, true; g != e {
244 - t.Fatalf("wrong Has: %v != %v", g, e)
245 - }
246 -}
247 -
248 -func TestDeleteNotFound(t *testing.T) {
249 - temp, cleanup := tempdir(t)
250 - defer cleanup()
251 -
252 - fs, err := flatfs.New(temp, 2, false)
253 - if err != nil {
254 - t.Fatalf("New fail: %v\n", err)
255 - }
256 -
257 - err = fs.Delete(datastore.NewKey("quux"))
258 - if g, e := err, datastore.ErrNotFound; g != e {
259 - t.Fatalf("expected ErrNotFound, got: %v\n", g)
260 - }
261 -}
262 -
263 -func TestDeleteFound(t *testing.T) {
264 - temp, cleanup := tempdir(t)
265 - defer cleanup()
266 -
267 - fs, err := flatfs.New(temp, 2, false)
268 - if err != nil {
269 - t.Fatalf("New fail: %v\n", err)
270 - }
271 - err = fs.Put(datastore.NewKey("quux"), []byte("foobar"))
272 - if err != nil {
273 - t.Fatalf("Put fail: %v\n", err)
274 - }
275 -
276 - err = fs.Delete(datastore.NewKey("quux"))
277 - if err != nil {
278 - t.Fatalf("Delete fail: %v\n", err)
279 - }
280 -
281 - // check that it's gone
282 - _, err = fs.Get(datastore.NewKey("quux"))
283 - if g, e := err, datastore.ErrNotFound; g != e {
284 - t.Fatalf("expected Get after Delete to give ErrNotFound, got: %v\n", g)
285 - }
286 -}
287 -
288 -func TestQuerySimple(t *testing.T) {
289 - temp, cleanup := tempdir(t)
290 - defer cleanup()
291 -
292 - fs, err := flatfs.New(temp, 2, false)
293 - if err != nil {
294 - t.Fatalf("New fail: %v\n", err)
295 - }
296 - const myKey = "quux"
297 - err = fs.Put(datastore.NewKey(myKey), []byte("foobar"))
298 - if err != nil {
299 - t.Fatalf("Put fail: %v\n", err)
300 - }
301 -
302 - res, err := fs.Query(query.Query{KeysOnly: true})
303 - if err != nil {
304 - t.Fatalf("Query fail: %v\n", err)
305 - }
306 - entries, err := res.Rest()
307 - if err != nil {
308 - t.Fatalf("Query Results.Rest fail: %v\n", err)
309 - }
310 - seen := false
311 - for _, e := range entries {
312 - switch e.Key {
313 - case datastore.NewKey(myKey).String():
314 - seen = true
315 - default:
316 - t.Errorf("saw unexpected key: %q", e.Key)
317 - }
318 - }
319 - if !seen {
320 - t.Errorf("did not see wanted key %q in %+v", myKey, entries)
321 - }
322 -}
323 -
324 -func TestBatchPut(t *testing.T) {
325 - temp, cleanup := tempdir(t)
326 - defer cleanup()
327 -
328 - fs, err := flatfs.New(temp, 2, false)
329 - if err != nil {
330 - t.Fatalf("New fail: %v\n", err)
331 - }
332 -
333 - dstest.RunBatchTest(t, fs)
334 -}
335 -
336 -func TestBatchDelete(t *testing.T) {
337 - temp, cleanup := tempdir(t)
338 - defer cleanup()
339 -
340 - fs, err := flatfs.New(temp, 2, false)
341 - if err != nil {
342 - t.Fatalf("New fail: %v\n", err)
343 - }
344 -
345 - dstest.RunBatchDeleteTest(t, fs)
346 -}
347 -
348 -func BenchmarkConsecutivePut(b *testing.B) {
349 - r := rand.New()
350 - var blocks [][]byte
351 - var keys []datastore.Key
352 - for i := 0; i < b.N; i++ {
353 - blk := make([]byte, 256*1024)
354 - r.Read(blk)
355 - blocks = append(blocks, blk)
356 -
357 - key := base32.StdEncoding.EncodeToString(blk[:8])
358 - keys = append(keys, datastore.NewKey(key))
359 - }
360 - temp, cleanup := tempdir(b)
361 - defer cleanup()
362 -
363 - fs, err := flatfs.New(temp, 2, false)
364 - if err != nil {
365 - b.Fatalf("New fail: %v\n", err)
366 - }
367 -
368 - b.ResetTimer()
369 -
370 - for i := 0; i < b.N; i++ {
371 - err := fs.Put(keys[i], blocks[i])
372 - if err != nil {
373 - b.Fatal(err)
374 - }
375 - }
376 -}
377 -
378 -func BenchmarkBatchedPut(b *testing.B) {
379 - r := rand.New()
380 - var blocks [][]byte
381 - var keys []datastore.Key
382 - for i := 0; i < b.N; i++ {
383 - blk := make([]byte, 256*1024)
384 - r.Read(blk)
385 - blocks = append(blocks, blk)
386 -
387 - key := base32.StdEncoding.EncodeToString(blk[:8])
388 - keys = append(keys, datastore.NewKey(key))
389 - }
390 - temp, cleanup := tempdir(b)
391 - defer cleanup()
392 -
393 - fs, err := flatfs.New(temp, 2, false)
394 - if err != nil {
395 - b.Fatalf("New fail: %v\n", err)
396 - }
397 -
398 - b.ResetTimer()
399 -
400 - for i := 0; i < b.N; {
401 - batch, err := fs.Batch()
402 - if err != nil {
403 - b.Fatal(err)
404 - }
405 -
406 - for n := i; i-n < 512 && i < b.N; i++ {
407 - err := batch.Put(keys[i], blocks[i])
408 - if err != nil {
409 - b.Fatal(err)
410 - }
411 - }
412 - err = batch.Commit()
413 - if err != nil {
414 - b.Fatal(err)
415 - }
416 - }
417 -}
Godeps/_workspace/src/github.com/jbenet/go-datastore/fs/fs_test.go deleted
-96
@@ -1,96 +0,0 @@
1 -package fs_test
2 -
3 -import (
4 - "bytes"
5 - "testing"
6 -
7 - . "launchpad.net/gocheck"
8 -
9 - ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore"
10 - fs "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore/fs"
11 - query "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore/query"
12 -)
13 -
14 -// Hook up gocheck into the "go test" runner.
15 -func Test(t *testing.T) { TestingT(t) }
16 -
17 -type DSSuite struct {
18 - dir string
19 - ds ds.Datastore
20 -}
21 -
22 -var _ = Suite(&DSSuite{})
23 -
24 -func (ks *DSSuite) SetUpTest(c *C) {
25 - ks.dir = c.MkDir()
26 - ks.ds, _ = fs.NewDatastore(ks.dir)
27 -}
28 -
29 -func (ks *DSSuite) TestOpen(c *C) {
30 - _, err := fs.NewDatastore("/tmp/foo/bar/baz")
31 - c.Assert(err, Not(Equals), nil)
32 -
33 - // setup ds
34 - _, err = fs.NewDatastore(ks.dir)
35 - c.Assert(err, Equals, nil)
36 -}
37 -
38 -func (ks *DSSuite) TestBasic(c *C) {
39 -
40 - keys := strsToKeys([]string{
41 - "foo",
42 - "foo/bar",
43 - "foo/bar/baz",
44 - "foo/barb",
45 - "foo/bar/bazb",
46 - "foo/bar/baz/barb",
47 - })
48 -
49 - for _, k := range keys {
50 - err := ks.ds.Put(k, []byte(k.String()))
51 - c.Check(err, Equals, nil)
52 - }
53 -
54 - for _, k := range keys {
55 - v, err := ks.ds.Get(k)
56 - c.Check(err, Equals, nil)
57 - c.Check(bytes.Equal(v.([]byte), []byte(k.String())), Equals, true)
58 - }
59 -
60 - r, err := ks.ds.Query(query.Query{Prefix: "/foo/bar/"})
61 - if err != nil {
62 - c.Check(err, Equals, nil)
63 - }
64 -
65 - expect := []string{
66 - "/foo/bar/baz",
67 - "/foo/bar/bazb",
68 - "/foo/bar/baz/barb",
69 - }
70 - all, err := r.Rest()
71 - if err != nil {
72 - c.Fatal(err)
73 - }
74 - c.Check(len(all), Equals, len(expect))
75 -
76 - for _, k := range expect {
77 - found := false
78 - for _, e := range all {
79 - if e.Key == k {
80 - found = true
81 - }
82 - }
83 -
84 - if !found {
85 - c.Error("did not find expected key: ", k)
86 - }
87 - }
88 -}
89 -
90 -func strsToKeys(strs []string) []ds.Key {
91 - keys := make([]ds.Key, len(strs))
92 - for i, s := range strs {
93 - keys[i] = ds.NewKey(s)
94 - }
95 - return keys
96 -}
Godeps/_workspace/src/github.com/jbenet/go-datastore/key_test.go deleted
-157
@@ -1,157 +0,0 @@
1 -package datastore_test
2 -
3 -import (
4 - "bytes"
5 - "math/rand"
6 - "path"
7 - "strings"
8 - "testing"
9 -
10 - . "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore"
11 - . "gopkg.in/check.v1"
12 -)
13 -
14 -// Hook up gocheck into the "go test" runner.
15 -func Test(t *testing.T) { TestingT(t) }
16 -
17 -func randomString() string {
18 - chars := "abcdefghijklmnopqrstuvwxyz1234567890"
19 - var buf bytes.Buffer
20 - l := rand.Intn(50)
21 - for j := 0; j < l; j++ {
22 - buf.WriteByte(chars[rand.Intn(len(chars))])
23 - }
24 - return buf.String()
25 -}
26 -
27 -type KeySuite struct{}
28 -
29 -var _ = Suite(&KeySuite{})
30 -
31 -func (ks *KeySuite) SubtestKey(s string, c *C) {
32 - fixed := path.Clean("/" + s)
33 - namespaces := strings.Split(fixed, "/")[1:]
34 - lastNamespace := namespaces[len(namespaces)-1]
35 - lnparts := strings.Split(lastNamespace, ":")
36 - ktype := ""
37 - if len(lnparts) > 1 {
38 - ktype = strings.Join(lnparts[:len(lnparts)-1], ":")
39 - }
40 - kname := lnparts[len(lnparts)-1]
41 -
42 - kchild := path.Clean(fixed + "/cchildd")
43 - kparent := "/" + strings.Join(append(namespaces[:len(namespaces)-1]), "/")
44 - kpath := path.Clean(kparent + "/" + ktype)
45 - kinstance := fixed + ":" + "inst"
46 -
47 - c.Log("Testing: ", NewKey(s))
48 -
49 - c.Check(NewKey(s).String(), Equals, fixed)
50 - c.Check(NewKey(s), Equals, NewKey(s))
51 - c.Check(NewKey(s).String(), Equals, NewKey(s).String())
52 - c.Check(NewKey(s).Name(), Equals, kname)
53 - c.Check(NewKey(s).Type(), Equals, ktype)
54 - c.Check(NewKey(s).Path().String(), Equals, kpath)
55 - c.Check(NewKey(s).Instance("inst").String(), Equals, kinstance)
56 -
57 - c.Check(NewKey(s).Child(NewKey("cchildd")).String(), Equals, kchild)
58 - c.Check(NewKey(s).Child(NewKey("cchildd")).Parent().String(), Equals, fixed)
59 - c.Check(NewKey(s).ChildString("cchildd").String(), Equals, kchild)
60 - c.Check(NewKey(s).ChildString("cchildd").Parent().String(), Equals, fixed)
61 - c.Check(NewKey(s).Parent().String(), Equals, kparent)
62 - c.Check(len(NewKey(s).List()), Equals, len(namespaces))
63 - c.Check(len(NewKey(s).Namespaces()), Equals, len(namespaces))
64 - for i, e := range NewKey(s).List() {
65 - c.Check(namespaces[i], Equals, e)
66 - }
67 -
68 - c.Check(NewKey(s), Equals, NewKey(s))
69 - c.Check(NewKey(s).Equal(NewKey(s)), Equals, true)
70 - c.Check(NewKey(s).Equal(NewKey("/fdsafdsa/"+s)), Equals, false)
71 -
72 - // less
73 - c.Check(NewKey(s).Less(NewKey(s).Parent()), Equals, false)
74 - c.Check(NewKey(s).Less(NewKey(s).ChildString("foo")), Equals, true)
75 -}
76 -
77 -func (ks *KeySuite) TestKeyBasic(c *C) {
78 - ks.SubtestKey("", c)
79 - ks.SubtestKey("abcde", c)
80 - ks.SubtestKey("disahfidsalfhduisaufidsail", c)
81 - ks.SubtestKey("/fdisahfodisa/fdsa/fdsafdsafdsafdsa/fdsafdsa/", c)
82 - ks.SubtestKey("4215432143214321432143214321", c)
83 - ks.SubtestKey("/fdisaha////fdsa////fdsafdsafdsafdsa/fdsafdsa/", c)
84 - ks.SubtestKey("abcde:fdsfd", c)
85 - ks.SubtestKey("disahfidsalfhduisaufidsail:fdsa", c)
86 - ks.SubtestKey("/fdisahfodisa/fdsa/fdsafdsafdsafdsa/fdsafdsa/:", c)
87 - ks.SubtestKey("4215432143214321432143214321:", c)
88 - ks.SubtestKey("fdisaha////fdsa////fdsafdsafdsafdsa/fdsafdsa/f:fdaf", c)
89 -}
90 -
91 -func CheckTrue(c *C, cond bool) {
92 - c.Check(cond, Equals, true)
93 -}
94 -
95 -func (ks *KeySuite) TestKeyAncestry(c *C) {
96 - k1 := NewKey("/A/B/C")
97 - k2 := NewKey("/A/B/C/D")
98 -
99 - c.Check(k1.String(), Equals, "/A/B/C")
100 - c.Check(k2.String(), Equals, "/A/B/C/D")
101 - CheckTrue(c, k1.IsAncestorOf(k2))
102 - CheckTrue(c, k2.IsDescendantOf(k1))
103 - CheckTrue(c, NewKey("/A").IsAncestorOf(k2))
104 - CheckTrue(c, NewKey("/A").IsAncestorOf(k1))
105 - CheckTrue(c, !NewKey("/A").IsDescendantOf(k2))
106 - CheckTrue(c, !NewKey("/A").IsDescendantOf(k1))
107 - CheckTrue(c, k2.IsDescendantOf(NewKey("/A")))
108 - CheckTrue(c, k1.IsDescendantOf(NewKey("/A")))
109 - CheckTrue(c, !k2.IsAncestorOf(NewKey("/A")))
110 - CheckTrue(c, !k1.IsAncestorOf(NewKey("/A")))
111 - CheckTrue(c, !k2.IsAncestorOf(k2))
112 - CheckTrue(c, !k1.IsAncestorOf(k1))
113 - c.Check(k1.Child(NewKey("D")).String(), Equals, k2.String())
114 - c.Check(k1.ChildString("D").String(), Equals, k2.String())
115 - c.Check(k1.String(), Equals, k2.Parent().String())
116 - c.Check(k1.Path().String(), Equals, k2.Parent().Path().String())
117 -}
118 -
119 -func (ks *KeySuite) TestType(c *C) {
120 - k1 := NewKey("/A/B/C:c")
121 - k2 := NewKey("/A/B/C:c/D:d")
122 -
123 - CheckTrue(c, k1.IsAncestorOf(k2))
124 - CheckTrue(c, k2.IsDescendantOf(k1))
125 - c.Check(k1.Type(), Equals, "C")
126 - c.Check(k2.Type(), Equals, "D")
127 - c.Check(k1.Type(), Equals, k2.Parent().Type())
128 -}
129 -
130 -func (ks *KeySuite) TestRandom(c *C) {
131 - keys := map[Key]bool{}
132 - for i := 0; i < 1000; i++ {
133 - r := RandomKey()
134 - _, found := keys[r]
135 - CheckTrue(c, !found)
136 - keys[r] = true
137 - }
138 - CheckTrue(c, len(keys) == 1000)
139 -}
140 -
141 -func (ks *KeySuite) TestLess(c *C) {
142 -
143 - checkLess := func(a, b string) {
144 - ak := NewKey(a)
145 - bk := NewKey(b)
146 - c.Check(ak.Less(bk), Equals, true)
147 - c.Check(bk.Less(ak), Equals, false)
148 - }
149 -
150 - checkLess("/a/b/c", "/a/b/c/d")
151 - checkLess("/a/b", "/a/b/c/d")
152 - checkLess("/a", "/a/b/c/d")
153 - checkLess("/a/a/c", "/a/b/c")
154 - checkLess("/a/a/d", "/a/b/c")
155 - checkLess("/a/b/c/d/e/f/g/h", "/b")
156 - checkLess("/", "/a")
157 -}
Godeps/_workspace/src/github.com/jbenet/go-datastore/keytransform/keytransform_test.go deleted
-99
@@ -1,99 +0,0 @@
1 -package keytransform_test
2 -
3 -import (
4 - "bytes"
5 - "sort"
6 - "testing"
7 -
8 - . "launchpad.net/gocheck"
9 -
10 - ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore"
11 - kt "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore/keytransform"
12 - dsq "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore/query"
13 -)
14 -
15 -// Hook up gocheck into the "go test" runner.
16 -func Test(t *testing.T) { TestingT(t) }
17 -
18 -type DSSuite struct{}
19 -
20 -var _ = Suite(&DSSuite{})
21 -
22 -func (ks *DSSuite) TestBasic(c *C) {
23 -
24 - pair := &kt.Pair{
25 - Convert: func(k ds.Key) ds.Key {
26 - return ds.NewKey("/abc").Child(k)
27 - },
28 - Invert: func(k ds.Key) ds.Key {
29 - // remove abc prefix
30 - l := k.List()
31 - if l[0] != "abc" {
32 - panic("key does not have prefix. convert failed?")
33 - }
34 - return ds.KeyWithNamespaces(l[1:])
35 - },
36 - }
37 -
38 - mpds := ds.NewMapDatastore()
39 - ktds := kt.Wrap(mpds, pair)
40 -
41 - keys := strsToKeys([]string{
42 - "foo",
43 - "foo/bar",
44 - "foo/bar/baz",
45 - "foo/barb",
46 - "foo/bar/bazb",
47 - "foo/bar/baz/barb",
48 - })
49 -
50 - for _, k := range keys {
51 - err := ktds.Put(k, []byte(k.String()))
52 - c.Check(err, Equals, nil)
53 - }
54 -
55 - for _, k := range keys {
56 - v1, err := ktds.Get(k)
57 - c.Check(err, Equals, nil)
58 - c.Check(bytes.Equal(v1.([]byte), []byte(k.String())), Equals, true)
59 -
60 - v2, err := mpds.Get(ds.NewKey("abc").Child(k))
61 - c.Check(err, Equals, nil)
62 - c.Check(bytes.Equal(v2.([]byte), []byte(k.String())), Equals, true)
63 - }
64 -
65 - run := func(d ds.Datastore, q dsq.Query) []ds.Key {
66 - r, err := d.Query(q)
67 - c.Check(err, Equals, nil)
68 -
69 - e, err := r.Rest()
70 - c.Check(err, Equals, nil)
71 -
72 - return ds.EntryKeys(e)
73 - }
74 -
75 - listA := run(mpds, dsq.Query{})
76 - listB := run(ktds, dsq.Query{})
77 - c.Check(len(listA), Equals, len(listB))
78 -
79 - // sort them cause yeah.
80 - sort.Sort(ds.KeySlice(listA))
81 - sort.Sort(ds.KeySlice(listB))
82 -
83 - for i, kA := range listA {
84 - kB := listB[i]
85 - c.Check(pair.Invert(kA), Equals, kB)
86 - c.Check(kA, Equals, pair.Convert(kB))
87 - }
88 -
89 - c.Log("listA: ", listA)
90 - c.Log("listB: ", listB)
91 -}
92 -
93 -func strsToKeys(strs []string) []ds.Key {
94 - keys := make([]ds.Key, len(strs))
95 - for i, s := range strs {
96 - keys[i] = ds.NewKey(s)
97 - }
98 - return keys
99 -}
Godeps/_workspace/src/github.com/jbenet/go-datastore/leveldb/ds_test.go deleted
-124
@@ -1,124 +0,0 @@
1 -package leveldb
2 -
3 -import (
4 - "io/ioutil"
5 - "os"
6 - "testing"
7 -
8 - ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore"
9 - dsq "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore/query"
10 -)
11 -
12 -var testcases = map[string]string{
13 - "/a": "a",
14 - "/a/b": "ab",
15 - "/a/b/c": "abc",
16 - "/a/b/d": "a/b/d",
17 - "/a/c": "ac",
18 - "/a/d": "ad",
19 - "/e": "e",
20 - "/f": "f",
21 -}
22 -
23 -// returns datastore, and a function to call on exit.
24 -// (this garbage collects). So:
25 -//
26 -// d, close := newDS(t)
27 -// defer close()
28 -func newDS(t *testing.T) (*datastore, func()) {
29 - path, err := ioutil.TempDir("/tmp", "testing_leveldb_")
30 - if err != nil {
31 - t.Fatal(err)
32 - }
33 -
34 - d, err := NewDatastore(path, nil)
35 - if err != nil {
36 - t.Fatal(err)
37 - }
38 - return d, func() {
39 - os.RemoveAll(path)
40 - d.Close()
41 - }
42 -}
43 -
44 -func addTestCases(t *testing.T, d *datastore, testcases map[string]string) {
45 - for k, v := range testcases {
46 - dsk := ds.NewKey(k)
47 - if err := d.Put(dsk, []byte(v)); err != nil {
48 - t.Fatal(err)
49 - }
50 - }
51 -
52 - for k, v := range testcases {
53 - dsk := ds.NewKey(k)
54 - v2, err := d.Get(dsk)
55 - if err != nil {
56 - t.Fatal(err)
57 - }
58 - v2b := v2.([]byte)
59 - if string(v2b) != v {
60 - t.Errorf("%s values differ: %s != %s", k, v, v2)
61 - }
62 - }
63 -
64 -}
65 -
66 -func TestQuery(t *testing.T) {
67 - d, close := newDS(t)
68 - defer close()
69 - addTestCases(t, d, testcases)
70 -
71 - rs, err := d.Query(dsq.Query{Prefix: "/a/"})
72 - if err != nil {
73 - t.Fatal(err)
74 - }
75 -
76 - expectMatches(t, []string{
77 - "/a/b",
78 - "/a/b/c",
79 - "/a/b/d",
80 - "/a/c",
81 - "/a/d",
82 - }, rs)
83 -
84 - // test offset and limit
85 -
86 - rs, err = d.Query(dsq.Query{Prefix: "/a/", Offset: 2, Limit: 2})
87 - if err != nil {
88 - t.Fatal(err)
89 - }
90 -
91 - expectMatches(t, []string{
92 - "/a/b/d",
93 - "/a/c",
94 - }, rs)
95 -
96 -}
97 -
98 -func TestQueryRespectsProcess(t *testing.T) {
99 - d, close := newDS(t)
100 - defer close()
101 - addTestCases(t, d, testcases)
102 -}
103 -
104 -func expectMatches(t *testing.T, expect []string, actualR dsq.Results) {
105 - actual, err := actualR.Rest()
106 - if err != nil {
107 - t.Error(err)
108 - }
109 -
110 - if len(actual) != len(expect) {
111 - t.Error("not enough", expect, actual)
112 - }
113 - for _, k := range expect {
114 - found := false
115 - for _, e := range actual {
116 - if e.Key == k {
117 - found = true
118 - }
119 - }
120 - if !found {
121 - t.Error(k, "not found")
122 - }
123 - }
124 -}
Godeps/_workspace/src/github.com/jbenet/go-datastore/lru/datastore_test.go deleted
-52
@@ -1,52 +0,0 @@
1 -package lru_test
2 -
3 -import (
4 - "strconv"
5 - "testing"
6 -
7 - ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore"
8 - lru "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore/lru"
9 - . "gopkg.in/check.v1"
10 -)
11 -
12 -// Hook up gocheck into the "go test" runner.
13 -func Test(t *testing.T) { TestingT(t) }
14 -
15 -type DSSuite struct{}
16 -
17 -var _ = Suite(&DSSuite{})
18 -
19 -func (ks *DSSuite) TestBasic(c *C) {
20 - var size = 1000
21 -
22 - d, err := lru.NewDatastore(size)
23 - c.Check(err, Equals, nil)
24 -
25 - for i := 0; i < size; i++ {
26 - err := d.Put(ds.NewKey(strconv.Itoa(i)), i)
27 - c.Check(err, Equals, nil)
28 - }
29 -
30 - for i := 0; i < size; i++ {
31 - j, err := d.Get(ds.NewKey(strconv.Itoa(i)))
32 - c.Check(j, Equals, i)
33 - c.Check(err, Equals, nil)
34 - }
35 -
36 - for i := 0; i < size; i++ {
37 - err := d.Put(ds.NewKey(strconv.Itoa(i+size)), i)
38 - c.Check(err, Equals, nil)
39 - }
40 -
41 - for i := 0; i < size; i++ {
42 - j, err := d.Get(ds.NewKey(strconv.Itoa(i)))
43 - c.Check(j, Equals, nil)
44 - c.Check(err, Equals, ds.ErrNotFound)
45 - }
46 -
47 - for i := 0; i < size; i++ {
48 - j, err := d.Get(ds.NewKey(strconv.Itoa(i + size)))
49 - c.Check(j, Equals, i)
50 - c.Check(err, Equals, nil)
51 - }
52 -}
Godeps/_workspace/src/github.com/jbenet/go-datastore/mount/mount_test.go deleted
-241
@@ -1,241 +0,0 @@
1 -package mount_test
2 -
3 -import (
4 - "testing"
5 -
6 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore"
7 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore/mount"
8 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore/query"
9 -)
10 -
11 -func TestPutBadNothing(t *testing.T) {
12 - m := mount.New(nil)
13 -
14 - err := m.Put(datastore.NewKey("quux"), []byte("foobar"))
15 - if g, e := err, mount.ErrNoMount; g != e {
16 - t.Fatalf("Put got wrong error: %v != %v", g, e)
17 - }
18 -}
19 -
20 -func TestPutBadNoMount(t *testing.T) {
21 - mapds := datastore.NewMapDatastore()
22 - m := mount.New([]mount.Mount{
23 - {Prefix: datastore.NewKey("/redherring"), Datastore: mapds},
24 - })
25 -
26 - err := m.Put(datastore.NewKey("/quux/thud"), []byte("foobar"))
27 - if g, e := err, mount.ErrNoMount; g != e {
28 - t.Fatalf("expected ErrNoMount, got: %v\n", g)
29 - }
30 -}
31 -
32 -func TestPut(t *testing.T) {
33 - mapds := datastore.NewMapDatastore()
34 - m := mount.New([]mount.Mount{
35 - {Prefix: datastore.NewKey("/quux"), Datastore: mapds},
36 - })
37 -
38 - if err := m.Put(datastore.NewKey("/quux/thud"), []byte("foobar")); err != nil {
39 - t.Fatalf("Put error: %v", err)
40 - }
41 -
42 - val, err := mapds.Get(datastore.NewKey("/thud"))
43 - if err != nil {
44 - t.Fatalf("Get error: %v", err)
45 - }
46 - buf, ok := val.([]byte)
47 - if !ok {
48 - t.Fatalf("Get value is not []byte: %T %v", val, val)
49 - }
50 - if g, e := string(buf), "foobar"; g != e {
51 - t.Errorf("wrong value: %q != %q", g, e)
52 - }
53 -}
54 -
55 -func TestGetBadNothing(t *testing.T) {
56 - m := mount.New([]mount.Mount{})
57 -
58 - _, err := m.Get(datastore.NewKey("/quux/thud"))
59 - if g, e := err, datastore.ErrNotFound; g != e {
60 - t.Fatalf("expected ErrNotFound, got: %v\n", g)
61 - }
62 -}
63 -
64 -func TestGetBadNoMount(t *testing.T) {
65 - mapds := datastore.NewMapDatastore()
66 - m := mount.New([]mount.Mount{
67 - {Prefix: datastore.NewKey("/redherring"), Datastore: mapds},
68 - })
69 -
70 - _, err := m.Get(datastore.NewKey("/quux/thud"))
71 - if g, e := err, datastore.ErrNotFound; g != e {
72 - t.Fatalf("expected ErrNotFound, got: %v\n", g)
73 - }
74 -}
75 -
76 -func TestGetNotFound(t *testing.T) {
77 - mapds := datastore.NewMapDatastore()
78 - m := mount.New([]mount.Mount{
79 - {Prefix: datastore.NewKey("/quux"), Datastore: mapds},
80 - })
81 -
82 - _, err := m.Get(datastore.NewKey("/quux/thud"))
83 - if g, e := err, datastore.ErrNotFound; g != e {
84 - t.Fatalf("expected ErrNotFound, got: %v\n", g)
85 - }
86 -}
87 -
88 -func TestGet(t *testing.T) {
89 - mapds := datastore.NewMapDatastore()
90 - m := mount.New([]mount.Mount{
91 - {Prefix: datastore.NewKey("/quux"), Datastore: mapds},
92 - })
93 -
94 - if err := mapds.Put(datastore.NewKey("/thud"), []byte("foobar")); err != nil {
95 - t.Fatalf("Get error: %v", err)
96 - }
97 -
98 - val, err := m.Get(datastore.NewKey("/quux/thud"))
99 - if err != nil {
100 - t.Fatalf("Put error: %v", err)
101 - }
102 -
103 - buf, ok := val.([]byte)
104 - if !ok {
105 - t.Fatalf("Get value is not []byte: %T %v", val, val)
106 - }
107 - if g, e := string(buf), "foobar"; g != e {
108 - t.Errorf("wrong value: %q != %q", g, e)
109 - }
110 -}
111 -
112 -func TestHasBadNothing(t *testing.T) {
113 - m := mount.New([]mount.Mount{})
114 -
115 - found, err := m.Has(datastore.NewKey("/quux/thud"))
116 - if err != nil {
117 - t.Fatalf("Has error: %v", err)
118 - }
119 - if g, e := found, false; g != e {
120 - t.Fatalf("wrong value: %v != %v", g, e)
121 - }
122 -}
123 -
124 -func TestHasBadNoMount(t *testing.T) {
125 - mapds := datastore.NewMapDatastore()
126 - m := mount.New([]mount.Mount{
127 - {Prefix: datastore.NewKey("/redherring"), Datastore: mapds},
128 - })
129 -
130 - found, err := m.Has(datastore.NewKey("/quux/thud"))
131 - if err != nil {
132 - t.Fatalf("Has error: %v", err)
133 - }
134 - if g, e := found, false; g != e {
135 - t.Fatalf("wrong value: %v != %v", g, e)
136 - }
137 -}
138 -
139 -func TestHasNotFound(t *testing.T) {
140 - mapds := datastore.NewMapDatastore()
141 - m := mount.New([]mount.Mount{
142 - {Prefix: datastore.NewKey("/quux"), Datastore: mapds},
143 - })
144 -
145 - found, err := m.Has(datastore.NewKey("/quux/thud"))
146 - if err != nil {
147 - t.Fatalf("Has error: %v", err)
148 - }
149 - if g, e := found, false; g != e {
150 - t.Fatalf("wrong value: %v != %v", g, e)
151 - }
152 -}
153 -
154 -func TestHas(t *testing.T) {
155 - mapds := datastore.NewMapDatastore()
156 - m := mount.New([]mount.Mount{
157 - {Prefix: datastore.NewKey("/quux"), Datastore: mapds},
158 - })
159 -
160 - if err := mapds.Put(datastore.NewKey("/thud"), []byte("foobar")); err != nil {
161 - t.Fatalf("Put error: %v", err)
162 - }
163 -
164 - found, err := m.Has(datastore.NewKey("/quux/thud"))
165 - if err != nil {
166 - t.Fatalf("Has error: %v", err)
167 - }
168 - if g, e := found, true; g != e {
169 - t.Fatalf("wrong value: %v != %v", g, e)
170 - }
171 -}
172 -
173 -func TestDeleteNotFound(t *testing.T) {
174 - mapds := datastore.NewMapDatastore()
175 - m := mount.New([]mount.Mount{
176 - {Prefix: datastore.NewKey("/quux"), Datastore: mapds},
177 - })
178 -
179 - err := m.Delete(datastore.NewKey("/quux/thud"))
180 - if g, e := err, datastore.ErrNotFound; g != e {
181 - t.Fatalf("expected ErrNotFound, got: %v\n", g)
182 - }
183 -}
184 -
185 -func TestDelete(t *testing.T) {
186 - mapds := datastore.NewMapDatastore()
187 - m := mount.New([]mount.Mount{
188 - {Prefix: datastore.NewKey("/quux"), Datastore: mapds},
189 - })
190 -
191 - if err := mapds.Put(datastore.NewKey("/thud"), []byte("foobar")); err != nil {
192 - t.Fatalf("Put error: %v", err)
193 - }
194 -
195 - err := m.Delete(datastore.NewKey("/quux/thud"))
196 - if err != nil {
197 - t.Fatalf("Delete error: %v", err)
198 - }
199 -
200 - // make sure it disappeared
201 - found, err := mapds.Has(datastore.NewKey("/thud"))
202 - if err != nil {
203 - t.Fatalf("Has error: %v", err)
204 - }
205 - if g, e := found, false; g != e {
206 - t.Fatalf("wrong value: %v != %v", g, e)
207 - }
208 -}
209 -
210 -func TestQuerySimple(t *testing.T) {
211 - mapds := datastore.NewMapDatastore()
212 - m := mount.New([]mount.Mount{
213 - {Prefix: datastore.NewKey("/quux"), Datastore: mapds},
214 - })
215 -
216 - const myKey = "/quux/thud"
217 - if err := m.Put(datastore.NewKey(myKey), []byte("foobar")); err != nil {
218 - t.Fatalf("Put error: %v", err)
219 - }
220 -
221 - res, err := m.Query(query.Query{Prefix: "/quux"})
222 - if err != nil {
223 - t.Fatalf("Query fail: %v\n", err)
224 - }
225 - entries, err := res.Rest()
226 - if err != nil {
227 - t.Fatalf("Query Results.Rest fail: %v\n", err)
228 - }
229 - seen := false
230 - for _, e := range entries {
231 - switch e.Key {
232 - case datastore.NewKey(myKey).String():
233 - seen = true
234 - default:
235 - t.Errorf("saw unexpected key: %q", e.Key)
236 - }
237 - }
238 - if !seen {
239 - t.Errorf("did not see wanted key %q in %+v", myKey, entries)
240 - }
241 -}
Godeps/_workspace/src/github.com/jbenet/go-datastore/namespace/example_test.go deleted
-30
@@ -1,30 +0,0 @@
1 -package namespace_test
2 -
3 -import (
4 - "fmt"
5 -
6 - ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore"
7 - nsds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore/namespace"
8 -)
9 -
10 -func Example() {
11 - mp := ds.NewMapDatastore()
12 - ns := nsds.Wrap(mp, ds.NewKey("/foo/bar"))
13 -
14 - k := ds.NewKey("/beep")
15 - v := "boop"
16 -
17 - ns.Put(k, v)
18 - fmt.Printf("ns.Put %s %s\n", k, v)
19 -
20 - v2, _ := ns.Get(k)
21 - fmt.Printf("ns.Get %s -> %s\n", k, v2)
22 -
23 - k3 := ds.NewKey("/foo/bar/beep")
24 - v3, _ := mp.Get(k3)
25 - fmt.Printf("mp.Get %s -> %s\n", k3, v3)
26 - // Output:
27 - // ns.Put /beep boop
28 - // ns.Get /beep -> boop
29 - // mp.Get /foo/bar/beep -> boop
30 -}
Godeps/_workspace/src/github.com/jbenet/go-datastore/namespace/namespace_test.go deleted
-82
@@ -1,82 +0,0 @@
1 -package namespace_test
2 -
3 -import (
4 - "bytes"
5 - "sort"
6 - "testing"
7 -
8 - . "launchpad.net/gocheck"
9 -
10 - ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore"
11 - ns "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore/namespace"
12 - dsq "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore/query"
13 -)
14 -
15 -// Hook up gocheck into the "go test" runner.
16 -func Test(t *testing.T) { TestingT(t) }
17 -
18 -type DSSuite struct{}
19 -
20 -var _ = Suite(&DSSuite{})
21 -
22 -func (ks *DSSuite) TestBasic(c *C) {
23 -
24 - mpds := ds.NewMapDatastore()
25 - nsds := ns.Wrap(mpds, ds.NewKey("abc"))
26 -
27 - keys := strsToKeys([]string{
28 - "foo",
29 - "foo/bar",
30 - "foo/bar/baz",
31 - "foo/barb",
32 - "foo/bar/bazb",
33 - "foo/bar/baz/barb",
34 - })
35 -
36 - for _, k := range keys {
37 - err := nsds.Put(k, []byte(k.String()))
38 - c.Check(err, Equals, nil)
39 - }
40 -
41 - for _, k := range keys {
42 - v1, err := nsds.Get(k)
43 - c.Check(err, Equals, nil)
44 - c.Check(bytes.Equal(v1.([]byte), []byte(k.String())), Equals, true)
45 -
46 - v2, err := mpds.Get(ds.NewKey("abc").Child(k))
47 - c.Check(err, Equals, nil)
48 - c.Check(bytes.Equal(v2.([]byte), []byte(k.String())), Equals, true)
49 - }
50 -
51 - run := func(d ds.Datastore, q dsq.Query) []ds.Key {
52 - r, err := d.Query(q)
53 - c.Check(err, Equals, nil)
54 -
55 - e, err := r.Rest()
56 - c.Check(err, Equals, nil)
57 -
58 - return ds.EntryKeys(e)
59 - }
60 -
61 - listA := run(mpds, dsq.Query{})
62 - listB := run(nsds, dsq.Query{})
63 - c.Check(len(listA), Equals, len(listB))
64 -
65 - // sort them cause yeah.
66 - sort.Sort(ds.KeySlice(listA))
67 - sort.Sort(ds.KeySlice(listB))
68 -
69 - for i, kA := range listA {
70 - kB := listB[i]
71 - c.Check(nsds.InvertKey(kA), Equals, kB)
72 - c.Check(kA, Equals, nsds.ConvertKey(kB))
73 - }
74 -}
75 -
76 -func strsToKeys(strs []string) []ds.Key {
77 - keys := make([]ds.Key, len(strs))
78 - for i, s := range strs {
79 - keys[i] = ds.NewKey(s)
80 - }
81 - return keys
82 -}
Godeps/_workspace/src/github.com/jbenet/go-datastore/query/filter_test.go deleted
-69
@@ -1,69 +0,0 @@
1 -package query
2 -
3 -import (
4 - "strings"
5 - "testing"
6 -)
7 -
8 -type filterTestCase struct {
9 - filter Filter
10 - keys []string
11 - expect []string
12 -}
13 -
14 -func testKeyFilter(t *testing.T, f Filter, keys []string, expect []string) {
15 - e := make([]Entry, len(keys))
16 - for i, k := range keys {
17 - e[i] = Entry{Key: k}
18 - }
19 -
20 - res := ResultsWithEntries(Query{}, e)
21 - res = NaiveFilter(res, f)
22 - actualE, err := res.Rest()
23 - if err != nil {
24 - t.Fatal(err)
25 - }
26 - actual := make([]string, len(actualE))
27 - for i, e := range actualE {
28 - actual[i] = e.Key
29 - }
30 -
31 - if len(actual) != len(expect) {
32 - t.Error("expect != actual.", expect, actual)
33 - }
34 -
35 - if strings.Join(actual, "") != strings.Join(expect, "") {
36 - t.Error("expect != actual.", expect, actual)
37 - }
38 -}
39 -
40 -func TestFilterKeyCompare(t *testing.T) {
41 -
42 - testKeyFilter(t, FilterKeyCompare{Equal, "/ab"}, sampleKeys, []string{"/ab"})
43 - testKeyFilter(t, FilterKeyCompare{GreaterThan, "/ab"}, sampleKeys, []string{
44 - "/ab/c",
45 - "/ab/cd",
46 - "/abce",
47 - "/abcf",
48 - })
49 - testKeyFilter(t, FilterKeyCompare{LessThanOrEqual, "/ab"}, sampleKeys, []string{
50 - "/a",
51 - "/ab",
52 - })
53 -}
54 -
55 -func TestFilterKeyPrefix(t *testing.T) {
56 -
57 - testKeyFilter(t, FilterKeyPrefix{"/a"}, sampleKeys, []string{
58 - "/ab/c",
59 - "/ab/cd",
60 - "/a",
61 - "/abce",
62 - "/abcf",
63 - "/ab",
64 - })
65 - testKeyFilter(t, FilterKeyPrefix{"/ab/"}, sampleKeys, []string{
66 - "/ab/c",
67 - "/ab/cd",
68 - })
69 -}
Godeps/_workspace/src/github.com/jbenet/go-datastore/query/order_test.go deleted
-59
@@ -1,59 +0,0 @@
1 -package query
2 -
3 -import (
4 - "strings"
5 - "testing"
6 -)
7 -
8 -type orderTestCase struct {
9 - order Order
10 - keys []string
11 - expect []string
12 -}
13 -
14 -func testKeyOrder(t *testing.T, f Order, keys []string, expect []string) {
15 - e := make([]Entry, len(keys))
16 - for i, k := range keys {
17 - e[i] = Entry{Key: k}
18 - }
19 -
20 - res := ResultsWithEntries(Query{}, e)
21 - res = NaiveOrder(res, f)
22 - actualE, err := res.Rest()
23 - if err != nil {
24 - t.Fatal(err)
25 - }
26 -
27 - actual := make([]string, len(actualE))
28 - for i, e := range actualE {
29 - actual[i] = e.Key
30 - }
31 -
32 - if len(actual) != len(expect) {
33 - t.Error("expect != actual.", expect, actual)
34 - }
35 -
36 - if strings.Join(actual, "") != strings.Join(expect, "") {
37 - t.Error("expect != actual.", expect, actual)
38 - }
39 -}
40 -
41 -func TestOrderByKey(t *testing.T) {
42 -
43 - testKeyOrder(t, OrderByKey{}, sampleKeys, []string{
44 - "/a",
45 - "/ab",
46 - "/ab/c",
47 - "/ab/cd",
48 - "/abce",
49 - "/abcf",
50 - })
51 - testKeyOrder(t, OrderByKeyDescending{}, sampleKeys, []string{
52 - "/abcf",
53 - "/abce",
54 - "/ab/cd",
55 - "/ab/c",
56 - "/ab",
57 - "/a",
58 - })
59 -}
Godeps/_workspace/src/github.com/jbenet/go-datastore/query/query_test.go deleted
-109
@@ -1,109 +0,0 @@
1 -package query
2 -
3 -import (
4 - "strings"
5 - "testing"
6 -)
7 -
8 -var sampleKeys = []string{
9 - "/ab/c",
10 - "/ab/cd",
11 - "/a",
12 - "/abce",
13 - "/abcf",
14 - "/ab",
15 -}
16 -
17 -type testCase struct {
18 - keys []string
19 - expect []string
20 -}
21 -
22 -func testResults(t *testing.T, res Results, expect []string) {
23 - actualE, err := res.Rest()
24 - if err != nil {
25 - t.Fatal(err)
26 - }
27 -
28 - actual := make([]string, len(actualE))
29 - for i, e := range actualE {
30 - actual[i] = e.Key
31 - }
32 -
33 - if len(actual) != len(expect) {
34 - t.Error("expect != actual.", expect, actual)
35 - }
36 -
37 - if strings.Join(actual, "") != strings.Join(expect, "") {
38 - t.Error("expect != actual.", expect, actual)
39 - }
40 -}
41 -
42 -func TestLimit(t *testing.T) {
43 - testKeyLimit := func(t *testing.T, limit int, keys []string, expect []string) {
44 - e := make([]Entry, len(keys))
45 - for i, k := range keys {
46 - e[i] = Entry{Key: k}
47 - }
48 -
49 - res := ResultsWithEntries(Query{}, e)
50 - res = NaiveLimit(res, limit)
51 - testResults(t, res, expect)
52 - }
53 -
54 - testKeyLimit(t, 0, sampleKeys, []string{ // none
55 - "/ab/c",
56 - "/ab/cd",
57 - "/a",
58 - "/abce",
59 - "/abcf",
60 - "/ab",
61 - })
62 -
63 - testKeyLimit(t, 10, sampleKeys, []string{ // large
64 - "/ab/c",
65 - "/ab/cd",
66 - "/a",
67 - "/abce",
68 - "/abcf",
69 - "/ab",
70 - })
71 -
72 - testKeyLimit(t, 2, sampleKeys, []string{
73 - "/ab/c",
74 - "/ab/cd",
75 - })
76 -}
77 -
78 -func TestOffset(t *testing.T) {
79 -
80 - testOffset := func(t *testing.T, offset int, keys []string, expect []string) {
81 - e := make([]Entry, len(keys))
82 - for i, k := range keys {
83 - e[i] = Entry{Key: k}
84 - }
85 -
86 - res := ResultsWithEntries(Query{}, e)
87 - res = NaiveOffset(res, offset)
88 - testResults(t, res, expect)
89 - }
90 -
91 - testOffset(t, 0, sampleKeys, []string{ // none
92 - "/ab/c",
93 - "/ab/cd",
94 - "/a",
95 - "/abce",
96 - "/abcf",
97 - "/ab",
98 - })
99 -
100 - testOffset(t, 10, sampleKeys, []string{ // large
101 - })
102 -
103 - testOffset(t, 2, sampleKeys, []string{
104 - "/a",
105 - "/abce",
106 - "/abcf",
107 - "/ab",
108 - })
109 -}
Godeps/_workspace/src/github.com/jbenet/go-datastore/redis/redis_test.go deleted
-109
@@ -1,109 +0,0 @@
1 -package redis
2 -
3 -import (
4 - "bytes"
5 - "os"
6 - "testing"
7 - "time"
8 -
9 - "github.com/fzzy/radix/redis"
10 - datastore "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore"
11 -
12 - dstest "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore/test"
13 -)
14 -
15 -const RedisEnv = "REDIS_DATASTORE_TEST_HOST"
16 -
17 -func TestPutGetBytes(t *testing.T) {
18 - client := clientOrAbort(t)
19 - ds, err := NewDatastore(client)
20 - if err != nil {
21 - t.Fatal(err)
22 - }
23 - key, val := datastore.NewKey("foo"), []byte("bar")
24 - dstest.Nil(ds.Put(key, val), t)
25 - v, err := ds.Get(key)
26 - if err != nil {
27 - t.Fatal(err)
28 - }
29 - if bytes.Compare(v.([]byte), val) != 0 {
30 - t.Fail()
31 - }
32 -}
33 -
34 -func TestHasBytes(t *testing.T) {
35 - client := clientOrAbort(t)
36 - ds, err := NewDatastore(client)
37 - if err != nil {
38 - t.Fatal(err)
39 - }
40 - key, val := datastore.NewKey("foo"), []byte("bar")
41 - has, err := ds.Has(key)
42 - if err != nil {
43 - t.Fatal(err)
44 - }
45 - if has {
46 - t.Fail()
47 - }
48 -
49 - dstest.Nil(ds.Put(key, val), t)
50 - hasAfterPut, err := ds.Has(key)
51 - if err != nil {
52 - t.Fatal(err)
53 - }
54 - if !hasAfterPut {
55 - t.Fail()
56 - }
57 -}
58 -
59 -func TestDelete(t *testing.T) {
60 - client := clientOrAbort(t)
61 - ds, err := NewDatastore(client)
62 - if err != nil {
63 - t.Fatal(err)
64 - }
65 - key, val := datastore.NewKey("foo"), []byte("bar")
66 - dstest.Nil(ds.Put(key, val), t)
67 - dstest.Nil(ds.Delete(key), t)
68 -
69 - hasAfterDelete, err := ds.Has(key)
70 - if err != nil {
71 - t.Fatal(err)
72 - }
73 - if hasAfterDelete {
74 - t.Fail()
75 - }
76 -}
77 -
78 -func TestExpiry(t *testing.T) {
79 - ttl := 1 * time.Second
80 - client := clientOrAbort(t)
81 - ds, err := NewExpiringDatastore(client, ttl)
82 - if err != nil {
83 - t.Fatal(err)
84 - }
85 - key, val := datastore.NewKey("foo"), []byte("bar")
86 - dstest.Nil(ds.Put(key, val), t)
87 - time.Sleep(ttl + 1*time.Second)
88 - dstest.Nil(ds.Delete(key), t)
89 -
90 - hasAfterExpiration, err := ds.Has(key)
91 - if err != nil {
92 - t.Fatal(err)
93 - }
94 - if hasAfterExpiration {
95 - t.Fail()
96 - }
97 -}
98 -
99 -func clientOrAbort(t *testing.T) *redis.Client {
100 - c, err := redis.Dial("tcp", os.Getenv(RedisEnv))
101 - if err != nil {
102 - t.Log("could not connect to a redis instance")
103 - t.SkipNow()
104 - }
105 - if err := c.Cmd("FLUSHALL").Err; err != nil {
106 - t.Fatal(err)
107 - }
108 - return c
109 -}
Godeps/_workspace/src/github.com/jbenet/go-datastore/syncmount/mount_test.go deleted
-241
@@ -1,241 +0,0 @@
1 -package syncmount_test
2 -
3 -import (
4 - "testing"
5 -
6 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore"
7 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore/mount"
8 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore/query"
9 -)
10 -
11 -func TestPutBadNothing(t *testing.T) {
12 - m := mount.New(nil)
13 -
14 - err := m.Put(datastore.NewKey("quux"), []byte("foobar"))
15 - if g, e := err, mount.ErrNoMount; g != e {
16 - t.Fatalf("Put got wrong error: %v != %v", g, e)
17 - }
18 -}
19 -
20 -func TestPutBadNoMount(t *testing.T) {
21 - mapds := datastore.NewMapDatastore()
22 - m := mount.New([]mount.Mount{
23 - {Prefix: datastore.NewKey("/redherring"), Datastore: mapds},
24 - })
25 -
26 - err := m.Put(datastore.NewKey("/quux/thud"), []byte("foobar"))
27 - if g, e := err, mount.ErrNoMount; g != e {
28 - t.Fatalf("expected ErrNoMount, got: %v\n", g)
29 - }
30 -}
31 -
32 -func TestPut(t *testing.T) {
33 - mapds := datastore.NewMapDatastore()
34 - m := mount.New([]mount.Mount{
35 - {Prefix: datastore.NewKey("/quux"), Datastore: mapds},
36 - })
37 -
38 - if err := m.Put(datastore.NewKey("/quux/thud"), []byte("foobar")); err != nil {
39 - t.Fatalf("Put error: %v", err)
40 - }
41 -
42 - val, err := mapds.Get(datastore.NewKey("/thud"))
43 - if err != nil {
44 - t.Fatalf("Get error: %v", err)
45 - }
46 - buf, ok := val.([]byte)
47 - if !ok {
48 - t.Fatalf("Get value is not []byte: %T %v", val, val)
49 - }
50 - if g, e := string(buf), "foobar"; g != e {
51 - t.Errorf("wrong value: %q != %q", g, e)
52 - }
53 -}
54 -
55 -func TestGetBadNothing(t *testing.T) {
56 - m := mount.New([]mount.Mount{})
57 -
58 - _, err := m.Get(datastore.NewKey("/quux/thud"))
59 - if g, e := err, datastore.ErrNotFound; g != e {
60 - t.Fatalf("expected ErrNotFound, got: %v\n", g)
61 - }
62 -}
63 -
64 -func TestGetBadNoMount(t *testing.T) {
65 - mapds := datastore.NewMapDatastore()
66 - m := mount.New([]mount.Mount{
67 - {Prefix: datastore.NewKey("/redherring"), Datastore: mapds},
68 - })
69 -
70 - _, err := m.Get(datastore.NewKey("/quux/thud"))
71 - if g, e := err, datastore.ErrNotFound; g != e {
72 - t.Fatalf("expected ErrNotFound, got: %v\n", g)
73 - }
74 -}
75 -
76 -func TestGetNotFound(t *testing.T) {
77 - mapds := datastore.NewMapDatastore()
78 - m := mount.New([]mount.Mount{
79 - {Prefix: datastore.NewKey("/quux"), Datastore: mapds},
80 - })
81 -
82 - _, err := m.Get(datastore.NewKey("/quux/thud"))
83 - if g, e := err, datastore.ErrNotFound; g != e {
84 - t.Fatalf("expected ErrNotFound, got: %v\n", g)
85 - }
86 -}
87 -
88 -func TestGet(t *testing.T) {
89 - mapds := datastore.NewMapDatastore()
90 - m := mount.New([]mount.Mount{
91 - {Prefix: datastore.NewKey("/quux"), Datastore: mapds},
92 - })
93 -
94 - if err := mapds.Put(datastore.NewKey("/thud"), []byte("foobar")); err != nil {
95 - t.Fatalf("Get error: %v", err)
96 - }
97 -
98 - val, err := m.Get(datastore.NewKey("/quux/thud"))
99 - if err != nil {
100 - t.Fatalf("Put error: %v", err)
101 - }
102 -
103 - buf, ok := val.([]byte)
104 - if !ok {
105 - t.Fatalf("Get value is not []byte: %T %v", val, val)
106 - }
107 - if g, e := string(buf), "foobar"; g != e {
108 - t.Errorf("wrong value: %q != %q", g, e)
109 - }
110 -}
111 -
112 -func TestHasBadNothing(t *testing.T) {
113 - m := mount.New([]mount.Mount{})
114 -
115 - found, err := m.Has(datastore.NewKey("/quux/thud"))
116 - if err != nil {
117 - t.Fatalf("Has error: %v", err)
118 - }
119 - if g, e := found, false; g != e {
120 - t.Fatalf("wrong value: %v != %v", g, e)
121 - }
122 -}
123 -
124 -func TestHasBadNoMount(t *testing.T) {
125 - mapds := datastore.NewMapDatastore()
126 - m := mount.New([]mount.Mount{
127 - {Prefix: datastore.NewKey("/redherring"), Datastore: mapds},
128 - })
129 -
130 - found, err := m.Has(datastore.NewKey("/quux/thud"))
131 - if err != nil {
132 - t.Fatalf("Has error: %v", err)
133 - }
134 - if g, e := found, false; g != e {
135 - t.Fatalf("wrong value: %v != %v", g, e)
136 - }
137 -}
138 -
139 -func TestHasNotFound(t *testing.T) {
140 - mapds := datastore.NewMapDatastore()
141 - m := mount.New([]mount.Mount{
142 - {Prefix: datastore.NewKey("/quux"), Datastore: mapds},
143 - })
144 -
145 - found, err := m.Has(datastore.NewKey("/quux/thud"))
146 - if err != nil {
147 - t.Fatalf("Has error: %v", err)
148 - }
149 - if g, e := found, false; g != e {
150 - t.Fatalf("wrong value: %v != %v", g, e)
151 - }
152 -}
153 -
154 -func TestHas(t *testing.T) {
155 - mapds := datastore.NewMapDatastore()
156 - m := mount.New([]mount.Mount{
157 - {Prefix: datastore.NewKey("/quux"), Datastore: mapds},
158 - })
159 -
160 - if err := mapds.Put(datastore.NewKey("/thud"), []byte("foobar")); err != nil {
161 - t.Fatalf("Put error: %v", err)
162 - }
163 -
164 - found, err := m.Has(datastore.NewKey("/quux/thud"))
165 - if err != nil {
166 - t.Fatalf("Has error: %v", err)
167 - }
168 - if g, e := found, true; g != e {
169 - t.Fatalf("wrong value: %v != %v", g, e)
170 - }
171 -}
172 -
173 -func TestDeleteNotFound(t *testing.T) {
174 - mapds := datastore.NewMapDatastore()
175 - m := mount.New([]mount.Mount{
176 - {Prefix: datastore.NewKey("/quux"), Datastore: mapds},
177 - })
178 -
179 - err := m.Delete(datastore.NewKey("/quux/thud"))
180 - if g, e := err, datastore.ErrNotFound; g != e {
181 - t.Fatalf("expected ErrNotFound, got: %v\n", g)
182 - }
183 -}
184 -
185 -func TestDelete(t *testing.T) {
186 - mapds := datastore.NewMapDatastore()
187 - m := mount.New([]mount.Mount{
188 - {Prefix: datastore.NewKey("/quux"), Datastore: mapds},
189 - })
190 -
191 - if err := mapds.Put(datastore.NewKey("/thud"), []byte("foobar")); err != nil {
192 - t.Fatalf("Put error: %v", err)
193 - }
194 -
195 - err := m.Delete(datastore.NewKey("/quux/thud"))
196 - if err != nil {
197 - t.Fatalf("Delete error: %v", err)
198 - }
199 -
200 - // make sure it disappeared
201 - found, err := mapds.Has(datastore.NewKey("/thud"))
202 - if err != nil {
203 - t.Fatalf("Has error: %v", err)
204 - }
205 - if g, e := found, false; g != e {
206 - t.Fatalf("wrong value: %v != %v", g, e)
207 - }
208 -}
209 -
210 -func TestQuerySimple(t *testing.T) {
211 - mapds := datastore.NewMapDatastore()
212 - m := mount.New([]mount.Mount{
213 - {Prefix: datastore.NewKey("/quux"), Datastore: mapds},
214 - })
215 -
216 - const myKey = "/quux/thud"
217 - if err := m.Put(datastore.NewKey(myKey), []byte("foobar")); err != nil {
218 - t.Fatalf("Put error: %v", err)
219 - }
220 -
221 - res, err := m.Query(query.Query{Prefix: "/quux"})
222 - if err != nil {
223 - t.Fatalf("Query fail: %v\n", err)
224 - }
225 - entries, err := res.Rest()
226 - if err != nil {
227 - t.Fatalf("Query Results.Rest fail: %v\n", err)
228 - }
229 - seen := false
230 - for _, e := range entries {
231 - switch e.Key {
232 - case datastore.NewKey(myKey).String():
233 - seen = true
234 - default:
235 - t.Errorf("saw unexpected key: %q", e.Key)
236 - }
237 - }
238 - if !seen {
239 - t.Errorf("did not see wanted key %q in %+v", myKey, entries)
240 - }
241 -}
Godeps/_workspace/src/github.com/jbenet/go-datastore/tiered/tiered_test.go deleted
-79
@@ -1,79 +0,0 @@
1 -package tiered
2 -
3 -import (
4 - "testing"
5 -
6 - ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore"
7 - dscb "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore/callback"
8 - dsq "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore/query"
9 -)
10 -
11 -func testHas(t *testing.T, dses []ds.Datastore, k ds.Key, v interface{}) {
12 - // all under should have it
13 - for _, d := range dses {
14 - if v2, err := d.Get(k); err != nil {
15 - t.Error(err)
16 - } else if v2 != v {
17 - t.Error("value incorrect", d, k, v, v2)
18 - }
19 -
20 - if has, err := d.Has(k); err != nil {
21 - t.Error(err)
22 - } else if !has {
23 - t.Error("should have it", d, k, v)
24 - }
25 - }
26 -}
27 -
28 -func testNotHas(t *testing.T, dses []ds.Datastore, k ds.Key) {
29 - // all under should not have it
30 - for _, d := range dses {
31 - if _, err := d.Get(k); err == nil {
32 - t.Error("should not have it", d, k)
33 - }
34 -
35 - if has, err := d.Has(k); err != nil {
36 - t.Error(err)
37 - } else if has {
38 - t.Error("should not have it", d, k)
39 - }
40 - }
41 -}
42 -
43 -func TestTiered(t *testing.T) {
44 - d1 := ds.NewMapDatastore()
45 - d2 := ds.NewMapDatastore()
46 - d3 := ds.NewMapDatastore()
47 - d4 := ds.NewMapDatastore()
48 -
49 - td := New(d1, d2, d3, d4)
50 - td.Put(ds.NewKey("foo"), "bar")
51 - testHas(t, []ds.Datastore{td}, ds.NewKey("foo"), "bar")
52 - testHas(t, td, ds.NewKey("foo"), "bar") // all children
53 -
54 - // remove it from, say, caches.
55 - d1.Delete(ds.NewKey("foo"))
56 - d2.Delete(ds.NewKey("foo"))
57 - testHas(t, []ds.Datastore{td}, ds.NewKey("foo"), "bar")
58 - testHas(t, td[2:], ds.NewKey("foo"), "bar")
59 - testNotHas(t, td[:2], ds.NewKey("foo"))
60 -
61 - // write it again.
62 - td.Put(ds.NewKey("foo"), "bar2")
63 - testHas(t, []ds.Datastore{td}, ds.NewKey("foo"), "bar2")
64 - testHas(t, td, ds.NewKey("foo"), "bar2")
65 -}
66 -
67 -func TestQueryCallsLast(t *testing.T) {
68 - var d1n, d2n, d3n int
69 - d1 := dscb.Wrap(ds.NewMapDatastore(), func() { d1n++ })
70 - d2 := dscb.Wrap(ds.NewMapDatastore(), func() { d2n++ })
71 - d3 := dscb.Wrap(ds.NewMapDatastore(), func() { d3n++ })
72 -
73 - td := New(d1, d2, d3)
74 -
75 - td.Query(dsq.Query{})
76 - if d3n < 1 {
77 - t.Error("should call last")
78 - }
79 -}
Godeps/_workspace/src/github.com/jbenet/go-datastore/timecache/timecache_test.go deleted
-64
@@ -1,64 +0,0 @@
1 -package timecache
2 -
3 -import (
4 - "testing"
5 - "time"
6 -
7 - ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore"
8 -)
9 -
10 -func testHas(t *testing.T, d ds.Datastore, k ds.Key, v interface{}) {
11 - if v2, err := d.Get(k); err != nil {
12 - t.Error(err)
13 - } else if v2 != v {
14 - t.Error("value incorrect", d, k, v, v2)
15 - }
16 -
17 - if has, err := d.Has(k); err != nil {
18 - t.Error(err)
19 - } else if !has {
20 - t.Error("should have it", d, k, v)
21 - }
22 -}
23 -
24 -func testNotHas(t *testing.T, d ds.Datastore, k ds.Key) {
25 - if _, err := d.Get(k); err == nil {
26 - t.Error("should not have it", d, k)
27 - }
28 -
29 - if has, err := d.Has(k); err != nil {
30 - t.Error(err)
31 - } else if has {
32 - t.Error("should not have it", d, k)
33 - }
34 -}
35 -
36 -func TestTimeCache(t *testing.T) {
37 - ttl := time.Millisecond * 100
38 - cache := WithTTL(ttl)
39 - cache.Put(ds.NewKey("foo1"), "bar1")
40 - cache.Put(ds.NewKey("foo2"), "bar2")
41 -
42 - <-time.After(ttl / 2)
43 - cache.Put(ds.NewKey("foo3"), "bar3")
44 - cache.Put(ds.NewKey("foo4"), "bar4")
45 - testHas(t, cache, ds.NewKey("foo1"), "bar1")
46 - testHas(t, cache, ds.NewKey("foo2"), "bar2")
47 - testHas(t, cache, ds.NewKey("foo3"), "bar3")
48 - testHas(t, cache, ds.NewKey("foo4"), "bar4")
49 -
50 - <-time.After(ttl / 2)
51 - testNotHas(t, cache, ds.NewKey("foo1"))
52 - testNotHas(t, cache, ds.NewKey("foo2"))
53 - testHas(t, cache, ds.NewKey("foo3"), "bar3")
54 - testHas(t, cache, ds.NewKey("foo4"), "bar4")
55 -
56 - cache.Delete(ds.NewKey("foo3"))
57 - testNotHas(t, cache, ds.NewKey("foo3"))
58 -
59 - <-time.After(ttl / 2)
60 - testNotHas(t, cache, ds.NewKey("foo1"))
61 - testNotHas(t, cache, ds.NewKey("foo2"))
62 - testNotHas(t, cache, ds.NewKey("foo3"))
63 - testNotHas(t, cache, ds.NewKey("foo4"))
64 -}
blocks/blockstore/blockstore.go
+3 -3
@@ -7,9 +7,9 @@ import (
7 "sync"
8 "sync/atomic"
9
10 - ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore"
11 - dsns "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore/namespace"
12 - dsq "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore/query"
10 + ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore"
11 + dsns "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore/namespace"
12 + dsq "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore/query"
13 mh "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multihash"
14 context "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
15 blocks "github.com/ipfs/go-ipfs/blocks"
blocks/blockstore/blockstore_test.go
+3 -3
@@ -5,9 +5,9 @@ import (
5 "fmt"
6 "testing"
7
8 - ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore"
9 - dsq "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore/query"
10 - ds_sync "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore/sync"
8 + ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore"
9 + dsq "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore/query"
10 + ds_sync "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore/sync"
11 context "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
12
13 blocks "github.com/ipfs/go-ipfs/blocks"
blocks/blockstore/write_cache_test.go
+3 -3
@@ -3,9 +3,9 @@ package blockstore
3 import (
4 "testing"
5
6 - ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore"
7 - dsq "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore/query"
8 - syncds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore/sync"
6 + ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore"
7 + dsq "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore/query"
8 + syncds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore/sync"
9 "github.com/ipfs/go-ipfs/blocks"
10 )
11
blocks/key/key.go
+1 -1
@@ -4,8 +4,8 @@ import (
4 "encoding/json"
5 "fmt"
6
7 + ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore"
8 b58 "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-base58"
8 - ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore"
9 mh "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multihash"
10 )
11
blockservice/test/blocks_test.go
+2 -2
@@ -5,8 +5,8 @@ import (
5 "testing"
6 "time"
7
8 - ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore"
9 - dssync "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore/sync"
8 + ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore"
9 + dssync "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore/sync"
10 "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
11 blocks "github.com/ipfs/go-ipfs/blocks"
12 blockstore "github.com/ipfs/go-ipfs/blocks/blockstore"
core/builder.go
+2 -2
@@ -5,8 +5,8 @@ import (
5 "encoding/base64"
6 "errors"
7
8 - ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore"
9 - dsync "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore/sync"
8 + ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore"
9 + dsync "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore/sync"
10 goprocessctx "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/goprocess/context"
11 context "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
12 bstore "github.com/ipfs/go-ipfs/blocks/blockstore"
core/core.go
+1 -1
@@ -16,8 +16,8 @@ import (
16 "net"
17 "time"
18
19 + ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore"
20 b58 "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-base58"
20 - ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore"
21 ma "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr"
22 goprocess "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/goprocess"
23 mamask "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/whyrusleeping/multiaddr-filter"
core/corerouting/core.go
+1 -1
@@ -3,7 +3,7 @@ package corerouting
3 import (
4 "errors"
5
6 - ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore"
6 + ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore"
7 context "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
8 core "github.com/ipfs/go-ipfs/core"
9 "github.com/ipfs/go-ipfs/p2p/host"
core/coreunix/add.go
+2 -2
@@ -8,8 +8,8 @@ import (
8 "os"
9 gopath "path"
10
11 - ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore"
12 - syncds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore/sync"
11 + ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore"
12 + syncds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore/sync"
13 context "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
14 bstore "github.com/ipfs/go-ipfs/blocks/blockstore"
15 key "github.com/ipfs/go-ipfs/blocks/key"
core/coreunix/metadata_test.go
+2 -2
@@ -5,8 +5,8 @@ import (
5 "io/ioutil"
6 "testing"
7
8 - ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore"
9 - dssync "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore/sync"
8 + ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore"
9 + dssync "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore/sync"
10 context "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
11
12 bstore "github.com/ipfs/go-ipfs/blocks/blockstore"
core/mock/mock.go
+2 -2
@@ -3,8 +3,8 @@ package coremock
3 import (
4 "net"
5
6 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore"
7 - syncds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore/sync"
6 + "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore"
7 + syncds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore/sync"
8 context "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
9
10 commands "github.com/ipfs/go-ipfs/commands"
exchange/bitswap/decision/engine_test.go
+2 -2
@@ -8,8 +8,8 @@ import (
8 "sync"
9 "testing"
10
11 - ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore"
12 - dssync "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore/sync"
11 + ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore"
12 + dssync "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore/sync"
13 context "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
14 blocks "github.com/ipfs/go-ipfs/blocks"
15 blockstore "github.com/ipfs/go-ipfs/blocks/blockstore"
exchange/bitswap/testnet/peernet.go
+1 -1
@@ -1,7 +1,7 @@
1 package bitswap
2
3 import (
4 - ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore"
4 + ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore"
5 context "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
6 bsnet "github.com/ipfs/go-ipfs/exchange/bitswap/network"
7 mockpeernet "github.com/ipfs/go-ipfs/p2p/net/mock"
exchange/bitswap/testutils.go
+2 -2
@@ -3,8 +3,8 @@ package bitswap
3 import (
4 "time"
5
6 - ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore"
7 - ds_sync "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore/sync"
6 + ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore"
7 + ds_sync "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore/sync"
8 context "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
9 blockstore "github.com/ipfs/go-ipfs/blocks/blockstore"
10 tn "github.com/ipfs/go-ipfs/exchange/bitswap/testnet"
exchange/offline/offline_test.go
+2 -2
@@ -3,8 +3,8 @@ package offline
3 import (
4 "testing"
5
6 - ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore"
7 - ds_sync "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore/sync"
6 + ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore"
7 + ds_sync "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore/sync"
8 context "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
9 blocks "github.com/ipfs/go-ipfs/blocks"
10 "github.com/ipfs/go-ipfs/blocks/blockstore"
exchange/reprovide/reprovide_test.go
+2 -2
@@ -3,8 +3,8 @@ package reprovide_test
3 import (
4 "testing"
5
6 - ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore"
7 - dssync "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore/sync"
6 + ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore"
7 + dssync "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore/sync"
8 context "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
9 blocks "github.com/ipfs/go-ipfs/blocks"
10 blockstore "github.com/ipfs/go-ipfs/blocks/blockstore"
merkledag/merkledag_test.go
+2 -2
@@ -10,8 +10,8 @@ import (
10 "sync"
11 "testing"
12
13 - ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore"
14 - dssync "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore/sync"
13 + ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore"
14 + dssync "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore/sync"
15 "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
16 bstore "github.com/ipfs/go-ipfs/blocks/blockstore"
17 key "github.com/ipfs/go-ipfs/blocks/key"
merkledag/test/utils.go
+2 -2
@@ -1,8 +1,8 @@
1 package mdutils
2
3 import (
4 - ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore"
5 - dssync "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore/sync"
4 + ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore"
5 + dssync "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore/sync"
6 "github.com/ipfs/go-ipfs/blocks/blockstore"
7 bsrv "github.com/ipfs/go-ipfs/blockservice"
8 "github.com/ipfs/go-ipfs/exchange/offline"
merkledag/utils/utils.go
+2 -2
@@ -3,8 +3,8 @@ package dagutils
3 import (
4 "errors"
5
6 - ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore"
7 - syncds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore/sync"
6 + ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore"
7 + syncds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore/sync"
8 context "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
9
10 bstore "github.com/ipfs/go-ipfs/blocks/blockstore"
mfs/mfs_test.go
+2 -2
@@ -10,8 +10,8 @@ import (
10 "sort"
11 "testing"
12
13 - ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore"
14 - dssync "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore/sync"
13 + ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore"
14 + dssync "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore/sync"
15 "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
16 "github.com/ipfs/go-ipfs/path"
17
namesys/namesys.go
+1 -1
@@ -4,7 +4,7 @@ import (
4 "strings"
5 "time"
6
7 - ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore"
7 + ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore"
8 context "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
9 ci "github.com/ipfs/go-ipfs/p2p/crypto"
10 path "github.com/ipfs/go-ipfs/path"
namesys/publisher.go
+1 -1
@@ -7,7 +7,7 @@ import (
7 "time"
8
9 proto "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/gogo/protobuf/proto"
10 - ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore"
10 + ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore"
11 context "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
12
13 key "github.com/ipfs/go-ipfs/blocks/key"
namesys/republisher/repub.go
+1 -1
@@ -14,7 +14,7 @@ import (
14 dhtpb "github.com/ipfs/go-ipfs/routing/dht/pb"
15
16 proto "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/gogo/protobuf/proto"
17 - ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore"
17 + ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore"
18 goprocess "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/goprocess"
19 gpctx "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/goprocess/context"
20 context "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
namesys/resolve_test.go
+1 -1
@@ -5,7 +5,7 @@ import (
5 "testing"
6 "time"
7
8 - ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore"
8 + ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore"
9 context "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
10 key "github.com/ipfs/go-ipfs/blocks/key"
11 peer "github.com/ipfs/go-ipfs/p2p/peer"
p2p/peer/peerstore.go
+2 -2
@@ -7,8 +7,8 @@ import (
7
8 ic "github.com/ipfs/go-ipfs/p2p/crypto"
9
10 - ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore"
11 - dssync "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore/sync"
10 + ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore"
11 + dssync "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore/sync"
12 ma "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr"
13 )
14
pin/pin.go
+1 -1
@@ -7,7 +7,7 @@ import (
7 "sync"
8 "time"
9
10 - ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore"
10 + ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore"
11 context "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
12 key "github.com/ipfs/go-ipfs/blocks/key"
13 "github.com/ipfs/go-ipfs/blocks/set"
pin/pin_test.go
+2 -2
@@ -6,8 +6,8 @@ import (
6
7 context "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
8
9 - ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore"
10 - dssync "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore/sync"
9 + ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore"
10 + dssync "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore/sync"
11 "github.com/ipfs/go-ipfs/blocks/blockstore"
12 key "github.com/ipfs/go-ipfs/blocks/key"
13 bs "github.com/ipfs/go-ipfs/blockservice"
pin/set_test.go
+2 -2
@@ -4,8 +4,8 @@ import (
4 "testing"
5 "testing/quick"
6
7 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore"
8 - dssync "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore/sync"
7 + "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore"
8 + dssync "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore/sync"
9 "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
10 "github.com/ipfs/go-ipfs/blocks/blockstore"
11 "github.com/ipfs/go-ipfs/blocks/key"
repo/fsrepo/defaultds.go
+5 -5
@@ -4,11 +4,11 @@ import (
4 "fmt"
5 "path"
6
7 - ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore"
8 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore/flatfs"
9 - levelds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore/leveldb"
10 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore/measure"
11 - mount "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore/syncmount"
7 + ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore"
8 + "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore/flatfs"
9 + levelds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore/leveldb"
10 + "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore/measure"
11 + mount "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore/syncmount"
12 ldbopts "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/opt"
13 repo "github.com/ipfs/go-ipfs/repo"
14 config "github.com/ipfs/go-ipfs/repo/config"
repo/fsrepo/fsrepo.go
+1 -1
@@ -11,7 +11,7 @@ import (
11 "strings"
12 "sync"
13
14 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore/measure"
14 + "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore/measure"
15 repo "github.com/ipfs/go-ipfs/repo"
16 "github.com/ipfs/go-ipfs/repo/common"
17 config "github.com/ipfs/go-ipfs/repo/config"
repo/fsrepo/fsrepo_test.go
+1 -1
@@ -5,7 +5,7 @@ import (
5 "io/ioutil"
6 "testing"
7
8 - datastore "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore"
8 + datastore "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore"
9 "github.com/ipfs/go-ipfs/repo/config"
10 "github.com/ipfs/go-ipfs/thirdparty/assert"
11 )
repo/repo.go
+1 -1
@@ -4,7 +4,7 @@ import (
4 "errors"
5 "io"
6
7 - ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore"
7 + ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore"
8 config "github.com/ipfs/go-ipfs/repo/config"
9 )
10
routing/dht/dht.go
+1 -1
@@ -21,7 +21,7 @@ import (
21 logging "github.com/ipfs/go-ipfs/vendor/QmQg1J6vikuXF9oDvm4wpdeAUvvkVEKW1EYDw9HhTMnP2b/go-log"
22
23 proto "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/gogo/protobuf/proto"
24 - ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore"
24 + ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore"
25 goprocess "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/goprocess"
26 goprocessctx "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/goprocess/context"
27 context "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
routing/dht/dht_test.go
+2 -2
@@ -9,8 +9,8 @@ import (
9 "testing"
10 "time"
11
12 - ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore"
13 - dssync "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore/sync"
12 + ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore"
13 + dssync "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore/sync"
14 ma "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr"
15 context "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
16
routing/dht/ext_test.go
+2 -2
@@ -8,8 +8,8 @@ import (
8 "time"
9
10 ggio "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/gogo/protobuf/io"
11 - ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore"
12 - dssync "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore/sync"
11 + ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore"
12 + dssync "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore/sync"
13 context "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
14
15 key "github.com/ipfs/go-ipfs/blocks/key"
routing/dht/handlers.go
+1 -1
@@ -6,7 +6,7 @@ import (
6 "time"
7
8 proto "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/gogo/protobuf/proto"
9 - ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore"
9 + ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore"
10 context "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
11 key "github.com/ipfs/go-ipfs/blocks/key"
12 peer "github.com/ipfs/go-ipfs/p2p/peer"
routing/mock/centralized_client.go
+1 -1
@@ -5,7 +5,7 @@ import (
5 "time"
6
7 proto "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/gogo/protobuf/proto"
8 - ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore"
8 + ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore"
9 ma "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr"
10 context "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
11 key "github.com/ipfs/go-ipfs/blocks/key"
routing/mock/centralized_server.go
+1 -1
@@ -5,7 +5,7 @@ import (
5 "sync"
6 "time"
7
8 - ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore"
8 + ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore"
9 context "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
10 key "github.com/ipfs/go-ipfs/blocks/key"
11 peer "github.com/ipfs/go-ipfs/p2p/peer"
routing/mock/dht.go
+2 -2
@@ -1,8 +1,8 @@
1 package mockrouting
2
3 import (
4 - ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore"
5 - sync "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore/sync"
4 + ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore"
5 + sync "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore/sync"
6 context "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
7 mocknet "github.com/ipfs/go-ipfs/p2p/net/mock"
8 dht "github.com/ipfs/go-ipfs/routing/dht"
routing/mock/interface.go
+1 -1
@@ -5,7 +5,7 @@
5 package mockrouting
6
7 import (
8 - ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore"
8 + ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore"
9 context "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
10 key "github.com/ipfs/go-ipfs/blocks/key"
11 peer "github.com/ipfs/go-ipfs/p2p/peer"
routing/offline/offline.go
+1 -1
@@ -5,7 +5,7 @@ import (
5 "time"
6
7 proto "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/gogo/protobuf/proto"
8 - ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore"
8 + ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore"
9 context "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
10 key "github.com/ipfs/go-ipfs/blocks/key"
11 ci "github.com/ipfs/go-ipfs/p2p/crypto"
routing/supernode/server.go
+1 -1
@@ -5,7 +5,7 @@ import (
5 "fmt"
6
7 proto "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/gogo/protobuf/proto"
8 - datastore "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore"
8 + datastore "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore"
9 context "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
10
11 key "github.com/ipfs/go-ipfs/blocks/key"
routing/supernode/server_test.go
+1 -1
@@ -3,7 +3,7 @@ package supernode
3 import (
4 "testing"
5
6 - datastore "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore"
6 + datastore "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore"
7 key "github.com/ipfs/go-ipfs/blocks/key"
8 dhtpb "github.com/ipfs/go-ipfs/routing/dht/pb"
9 )
test/integration/grandcentral_test.go
+2 -2
@@ -8,8 +8,8 @@ import (
8 "math"
9 "testing"
10
11 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore"
12 - syncds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore/sync"
11 + "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore"
12 + syncds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore/sync"
13 context "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
14
15 key "github.com/ipfs/go-ipfs/blocks/key"
test/supernode_client/main.go
+3 -3
@@ -17,8 +17,8 @@ import (
17 context "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
18 "github.com/ipfs/go-ipfs/util/ipfsaddr"
19
20 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore"
21 - syncds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore/sync"
20 + "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore"
21 + syncds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore/sync"
22 commands "github.com/ipfs/go-ipfs/commands"
23 core "github.com/ipfs/go-ipfs/core"
24 corehttp "github.com/ipfs/go-ipfs/core/corehttp"
@@ -225,7 +225,7 @@ func runFileCattingWorker(ctx context.Context, n *core.IpfsNode) error {
225 }
226 }()
227
228 - err = <- errs
228 + err = <-errs
229 if err != nil {
230 log.Fatal(err)
231 }
thirdparty/s3-datastore/datastore.go
+2 -2
@@ -5,8 +5,8 @@ import (
5 "errors"
6
7 "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/crowdmob/goamz/s3"
8 - datastore "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore"
9 - query "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore/query"
8 + datastore "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore"
9 + query "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore/query"
10 )
11
12 var _ datastore.ThreadSafeDatastore = &S3Datastore{}
unixfs/mod/dagmodifier_test.go
+2 -2
@@ -7,7 +7,7 @@ import (
7 "os"
8 "testing"
9
10 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore/sync"
10 + "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore/sync"
11 "github.com/ipfs/go-ipfs/blocks/blockstore"
12 bs "github.com/ipfs/go-ipfs/blockservice"
13 "github.com/ipfs/go-ipfs/exchange/offline"
@@ -20,7 +20,7 @@ import (
20 uio "github.com/ipfs/go-ipfs/unixfs/io"
21 u "github.com/ipfs/go-ipfs/util"
22
23 - ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore"
23 + ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore"
24 context "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
25 )
26
util/datastore2/datastore_closer.go
+1 -1
@@ -3,7 +3,7 @@ package datastore2
3 import (
4 "io"
5
6 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore"
6 + "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore"
7 )
8
9 type ThreadSafeDatastoreCloser interface {
util/datastore2/delayed.go
+2 -2
@@ -1,8 +1,8 @@
1 package datastore2
2
3 import (
4 - ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore"
5 - dsq "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore/query"
4 + ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore"
5 + dsq "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore/query"
6
7 delay "github.com/ipfs/go-ipfs/thirdparty/delay"
8 )
util/datastore2/threadsafe.go
+1 -1
@@ -3,7 +3,7 @@ package datastore2
3 import (
4 "io"
5
6 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore"
6 + "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore"
7 )
8
9 // ClaimThreadSafe claims that a Datastore is threadsafe, even when
util/testutil/datastore.go
+2 -2
@@ -1,8 +1,8 @@
1 package testutil
2
3 import (
4 - "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore"
5 - syncds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore/sync"
4 + "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore"
5 + syncds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore/sync"
6 ds2 "github.com/ipfs/go-ipfs/util/datastore2"
7 )
8
util/util.go
+1 -1
@@ -12,8 +12,8 @@ import (
12 "strings"
13 "time"
14
15 + ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/ipfs/go-datastore"
16 b58 "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-base58"
16 - ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore"
17 mh "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multihash"
18
19 "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/mitchellh/go-homedir"