Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
e53dab86
Unverified
提交
e53dab86
authored
1月 08, 2019
作者:
Steven Allen
提交者:
GitHub
1月 08, 2019
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #5900 from ipfs/fix/partial-api-tests
CoreAPI: Don't panic when testing incomplete implementions
上级
42a15ba7
81a2ffc4
隐藏空白字符变更
内嵌
并排
正在显示
11 个修改的文件
包含
116 行增加
和
9 行删除
+116
-9
api.go
core/coreapi/interface/tests/api.go
+16
-0
block.go
core/coreapi/interface/tests/block.go
+7
-0
dag.go
core/coreapi/interface/tests/dag.go
+7
-0
dht.go
core/coreapi/interface/tests/dht.go
+8
-0
key.go
core/coreapi/interface/tests/key.go
+8
-0
name.go
core/coreapi/interface/tests/name.go
+7
-0
object.go
core/coreapi/interface/tests/object.go
+7
-0
path.go
core/coreapi/interface/tests/path.go
+33
-9
pin.go
core/coreapi/interface/tests/pin.go
+8
-0
pubsub.go
core/coreapi/interface/tests/pubsub.go
+8
-0
unixfs.go
core/coreapi/interface/tests/unixfs.go
+7
-0
没有找到文件。
core/coreapi/interface/tests/api.go
浏览文件 @
e53dab86
...
@@ -2,12 +2,15 @@ package tests
...
@@ -2,12 +2,15 @@ package tests
import
(
import
(
"context"
"context"
"errors"
"testing"
"testing"
"time"
"time"
coreiface
"github.com/ipfs/go-ipfs/core/coreapi/interface"
coreiface
"github.com/ipfs/go-ipfs/core/coreapi/interface"
)
)
var
apiNotImplemented
=
errors
.
New
(
"api not implemented"
)
func
(
tp
*
provider
)
makeAPI
(
ctx
context
.
Context
)
(
coreiface
.
CoreAPI
,
error
)
{
func
(
tp
*
provider
)
makeAPI
(
ctx
context
.
Context
)
(
coreiface
.
CoreAPI
,
error
)
{
api
,
err
:=
tp
.
MakeAPISwarm
(
ctx
,
false
,
1
)
api
,
err
:=
tp
.
MakeAPISwarm
(
ctx
,
false
,
1
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -76,3 +79,16 @@ func TestApi(p Provider) func(t *testing.T) {
...
@@ -76,3 +79,16 @@ func TestApi(p Provider) func(t *testing.T) {
})
})
}
}
}
}
func
(
tp
*
provider
)
hasApi
(
t
*
testing
.
T
,
tf
func
(
coreiface
.
CoreAPI
)
error
)
{
ctx
,
cancel
:=
context
.
WithCancel
(
context
.
Background
())
defer
cancel
()
api
,
err
:=
tp
.
makeAPI
(
ctx
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
if
err
:=
tf
(
api
);
err
!=
nil
{
t
.
Fatal
(
api
)
}
}
core/coreapi/interface/tests/block.go
浏览文件 @
e53dab86
...
@@ -13,6 +13,13 @@ import (
...
@@ -13,6 +13,13 @@ import (
)
)
func
(
tp
*
provider
)
TestBlock
(
t
*
testing
.
T
)
{
func
(
tp
*
provider
)
TestBlock
(
t
*
testing
.
T
)
{
tp
.
hasApi
(
t
,
func
(
api
coreiface
.
CoreAPI
)
error
{
if
api
.
Block
()
==
nil
{
return
apiNotImplemented
}
return
nil
})
t
.
Run
(
"TestBlockPut"
,
tp
.
TestBlockPut
)
t
.
Run
(
"TestBlockPut"
,
tp
.
TestBlockPut
)
t
.
Run
(
"TestBlockPutFormat"
,
tp
.
TestBlockPutFormat
)
t
.
Run
(
"TestBlockPutFormat"
,
tp
.
TestBlockPutFormat
)
t
.
Run
(
"TestBlockPutHash"
,
tp
.
TestBlockPutHash
)
t
.
Run
(
"TestBlockPutHash"
,
tp
.
TestBlockPutHash
)
...
...
core/coreapi/interface/tests/dag.go
浏览文件 @
e53dab86
...
@@ -13,6 +13,13 @@ import (
...
@@ -13,6 +13,13 @@ import (
)
)
func
(
tp
*
provider
)
TestDag
(
t
*
testing
.
T
)
{
func
(
tp
*
provider
)
TestDag
(
t
*
testing
.
T
)
{
tp
.
hasApi
(
t
,
func
(
api
coreiface
.
CoreAPI
)
error
{
if
api
.
Dag
()
==
nil
{
return
apiNotImplemented
}
return
nil
})
t
.
Run
(
"TestPut"
,
tp
.
TestPut
)
t
.
Run
(
"TestPut"
,
tp
.
TestPut
)
t
.
Run
(
"TestPutWithHash"
,
tp
.
TestPutWithHash
)
t
.
Run
(
"TestPutWithHash"
,
tp
.
TestPutWithHash
)
t
.
Run
(
"TestPath"
,
tp
.
TestDagPath
)
t
.
Run
(
"TestPath"
,
tp
.
TestDagPath
)
...
...
core/coreapi/interface/tests/dht.go
浏览文件 @
e53dab86
...
@@ -5,10 +5,18 @@ import (
...
@@ -5,10 +5,18 @@ import (
"io"
"io"
"testing"
"testing"
"github.com/ipfs/go-ipfs/core/coreapi/interface"
"github.com/ipfs/go-ipfs/core/coreapi/interface/options"
"github.com/ipfs/go-ipfs/core/coreapi/interface/options"
)
)
func
(
tp
*
provider
)
TestDht
(
t
*
testing
.
T
)
{
func
(
tp
*
provider
)
TestDht
(
t
*
testing
.
T
)
{
tp
.
hasApi
(
t
,
func
(
api
iface
.
CoreAPI
)
error
{
if
api
.
Dht
()
==
nil
{
return
apiNotImplemented
}
return
nil
})
t
.
Run
(
"TestDhtFindPeer"
,
tp
.
TestDhtFindPeer
)
t
.
Run
(
"TestDhtFindPeer"
,
tp
.
TestDhtFindPeer
)
t
.
Run
(
"TestDhtFindProviders"
,
tp
.
TestDhtFindProviders
)
t
.
Run
(
"TestDhtFindProviders"
,
tp
.
TestDhtFindProviders
)
t
.
Run
(
"TestDhtProvide"
,
tp
.
TestDhtProvide
)
t
.
Run
(
"TestDhtProvide"
,
tp
.
TestDhtProvide
)
...
...
core/coreapi/interface/tests/key.go
浏览文件 @
e53dab86
...
@@ -5,10 +5,18 @@ import (
...
@@ -5,10 +5,18 @@ import (
"strings"
"strings"
"testing"
"testing"
"github.com/ipfs/go-ipfs/core/coreapi/interface"
opt
"github.com/ipfs/go-ipfs/core/coreapi/interface/options"
opt
"github.com/ipfs/go-ipfs/core/coreapi/interface/options"
)
)
func
(
tp
*
provider
)
TestKey
(
t
*
testing
.
T
)
{
func
(
tp
*
provider
)
TestKey
(
t
*
testing
.
T
)
{
tp
.
hasApi
(
t
,
func
(
api
iface
.
CoreAPI
)
error
{
if
api
.
Key
()
==
nil
{
return
apiNotImplemented
}
return
nil
})
t
.
Run
(
"TestListSelf"
,
tp
.
TestListSelf
)
t
.
Run
(
"TestListSelf"
,
tp
.
TestListSelf
)
t
.
Run
(
"TestRenameSelf"
,
tp
.
TestRenameSelf
)
t
.
Run
(
"TestRenameSelf"
,
tp
.
TestRenameSelf
)
t
.
Run
(
"TestRemoveSelf"
,
tp
.
TestRemoveSelf
)
t
.
Run
(
"TestRemoveSelf"
,
tp
.
TestRemoveSelf
)
...
...
core/coreapi/interface/tests/name.go
浏览文件 @
e53dab86
...
@@ -16,6 +16,13 @@ import (
...
@@ -16,6 +16,13 @@ import (
)
)
func
(
tp
*
provider
)
TestName
(
t
*
testing
.
T
)
{
func
(
tp
*
provider
)
TestName
(
t
*
testing
.
T
)
{
tp
.
hasApi
(
t
,
func
(
api
coreiface
.
CoreAPI
)
error
{
if
api
.
Name
()
==
nil
{
return
apiNotImplemented
}
return
nil
})
t
.
Run
(
"TestPublishResolve"
,
tp
.
TestPublishResolve
)
t
.
Run
(
"TestPublishResolve"
,
tp
.
TestPublishResolve
)
t
.
Run
(
"TestBasicPublishResolveKey"
,
tp
.
TestBasicPublishResolveKey
)
t
.
Run
(
"TestBasicPublishResolveKey"
,
tp
.
TestBasicPublishResolveKey
)
t
.
Run
(
"TestBasicPublishResolveTimeout"
,
tp
.
TestBasicPublishResolveTimeout
)
t
.
Run
(
"TestBasicPublishResolveTimeout"
,
tp
.
TestBasicPublishResolveTimeout
)
...
...
core/coreapi/interface/tests/object.go
浏览文件 @
e53dab86
...
@@ -13,6 +13,13 @@ import (
...
@@ -13,6 +13,13 @@ import (
)
)
func
(
tp
*
provider
)
TestObject
(
t
*
testing
.
T
)
{
func
(
tp
*
provider
)
TestObject
(
t
*
testing
.
T
)
{
tp
.
hasApi
(
t
,
func
(
api
iface
.
CoreAPI
)
error
{
if
api
.
Object
()
==
nil
{
return
apiNotImplemented
}
return
nil
})
t
.
Run
(
"TestNew"
,
tp
.
TestNew
)
t
.
Run
(
"TestNew"
,
tp
.
TestNew
)
t
.
Run
(
"TestObjectPut"
,
tp
.
TestObjectPut
)
t
.
Run
(
"TestObjectPut"
,
tp
.
TestObjectPut
)
t
.
Run
(
"TestObjectGet"
,
tp
.
TestObjectGet
)
t
.
Run
(
"TestObjectGet"
,
tp
.
TestObjectGet
)
...
...
core/coreapi/interface/tests/path.go
浏览文件 @
e53dab86
...
@@ -26,23 +26,27 @@ func (tp *provider) TestMutablePath(t *testing.T) {
...
@@ -26,23 +26,27 @@ func (tp *provider) TestMutablePath(t *testing.T) {
t
.
Fatal
(
err
)
t
.
Fatal
(
err
)
}
}
// get self /ipns path
blk
,
err
:=
api
.
Block
()
.
Put
(
ctx
,
strings
.
NewReader
(
`foo`
))
keys
,
err
:=
api
.
Key
()
.
List
(
ctx
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatal
(
err
)
t
.
Fatal
(
err
)
}
}
if
!
keys
[
0
]
.
Path
()
.
Mutable
()
{
if
blk
.
Path
()
.
Mutable
()
{
t
.
Error
(
"expected
self /ipns path to be
mutable"
)
t
.
Error
(
"expected
/ipld path to be im
mutable"
)
}
}
blk
,
err
:=
api
.
Block
()
.
Put
(
ctx
,
strings
.
NewReader
(
`foo`
))
// get self /ipns path
if
api
.
Key
()
==
nil
{
t
.
Fatal
(
".Key not implemented"
)
}
keys
,
err
:=
api
.
Key
()
.
List
(
ctx
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Error
(
err
)
t
.
Fatal
(
err
)
}
}
if
blk
.
Path
()
.
Mutable
()
{
if
!
keys
[
0
]
.
Path
()
.
Mutable
()
{
t
.
Error
(
"expected
/ipld path to be im
mutable"
)
t
.
Error
(
"expected
self /ipns path to be
mutable"
)
}
}
}
}
...
@@ -54,6 +58,10 @@ func (tp *provider) TestPathRemainder(t *testing.T) {
...
@@ -54,6 +58,10 @@ func (tp *provider) TestPathRemainder(t *testing.T) {
t
.
Fatal
(
err
)
t
.
Fatal
(
err
)
}
}
if
api
.
Dag
()
==
nil
{
t
.
Fatal
(
".Dag not implemented"
)
}
obj
,
err
:=
api
.
Dag
()
.
Put
(
ctx
,
strings
.
NewReader
(
`{"foo": {"bar": "baz"}}`
))
obj
,
err
:=
api
.
Dag
()
.
Put
(
ctx
,
strings
.
NewReader
(
`{"foo": {"bar": "baz"}}`
))
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatal
(
err
)
t
.
Fatal
(
err
)
...
@@ -82,6 +90,10 @@ func (tp *provider) TestEmptyPathRemainder(t *testing.T) {
...
@@ -82,6 +90,10 @@ func (tp *provider) TestEmptyPathRemainder(t *testing.T) {
t
.
Fatal
(
err
)
t
.
Fatal
(
err
)
}
}
if
api
.
Dag
()
==
nil
{
t
.
Fatal
(
".Dag not implemented"
)
}
obj
,
err
:=
api
.
Dag
()
.
Put
(
ctx
,
strings
.
NewReader
(
`{"foo": {"bar": "baz"}}`
))
obj
,
err
:=
api
.
Dag
()
.
Put
(
ctx
,
strings
.
NewReader
(
`{"foo": {"bar": "baz"}}`
))
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatal
(
err
)
t
.
Fatal
(
err
)
...
@@ -114,6 +126,10 @@ func (tp *provider) TestInvalidPathRemainder(t *testing.T) {
...
@@ -114,6 +126,10 @@ func (tp *provider) TestInvalidPathRemainder(t *testing.T) {
t
.
Fatal
(
err
)
t
.
Fatal
(
err
)
}
}
if
api
.
Dag
()
==
nil
{
t
.
Fatal
(
".Dag not implemented"
)
}
obj
,
err
:=
api
.
Dag
()
.
Put
(
ctx
,
strings
.
NewReader
(
`{"foo": {"bar": "baz"}}`
))
obj
,
err
:=
api
.
Dag
()
.
Put
(
ctx
,
strings
.
NewReader
(
`{"foo": {"bar": "baz"}}`
))
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatal
(
err
)
t
.
Fatal
(
err
)
...
@@ -138,9 +154,17 @@ func (tp *provider) TestPathRoot(t *testing.T) {
...
@@ -138,9 +154,17 @@ func (tp *provider) TestPathRoot(t *testing.T) {
t
.
Fatal
(
err
)
t
.
Fatal
(
err
)
}
}
if
api
.
Block
()
==
nil
{
t
.
Fatal
(
".Block not implemented"
)
}
blk
,
err
:=
api
.
Block
()
.
Put
(
ctx
,
strings
.
NewReader
(
`foo`
),
options
.
Block
.
Format
(
"raw"
))
blk
,
err
:=
api
.
Block
()
.
Put
(
ctx
,
strings
.
NewReader
(
`foo`
),
options
.
Block
.
Format
(
"raw"
))
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Error
(
err
)
t
.
Fatal
(
err
)
}
if
api
.
Dag
()
==
nil
{
t
.
Fatal
(
".Dag not implemented"
)
}
}
obj
,
err
:=
api
.
Dag
()
.
Put
(
ctx
,
strings
.
NewReader
(
`{"foo": {"/": "`
+
blk
.
Path
()
.
Cid
()
.
String
()
+
`"}}`
))
obj
,
err
:=
api
.
Dag
()
.
Put
(
ctx
,
strings
.
NewReader
(
`{"foo": {"/": "`
+
blk
.
Path
()
.
Cid
()
.
String
()
+
`"}}`
))
...
...
core/coreapi/interface/tests/pin.go
浏览文件 @
e53dab86
...
@@ -2,6 +2,7 @@ package tests
...
@@ -2,6 +2,7 @@ package tests
import
(
import
(
"context"
"context"
"github.com/ipfs/go-ipfs/core/coreapi/interface"
"strings"
"strings"
"testing"
"testing"
...
@@ -9,6 +10,13 @@ import (
...
@@ -9,6 +10,13 @@ import (
)
)
func
(
tp
*
provider
)
TestPin
(
t
*
testing
.
T
)
{
func
(
tp
*
provider
)
TestPin
(
t
*
testing
.
T
)
{
tp
.
hasApi
(
t
,
func
(
api
iface
.
CoreAPI
)
error
{
if
api
.
Pin
()
==
nil
{
return
apiNotImplemented
}
return
nil
})
t
.
Run
(
"TestPinAdd"
,
tp
.
TestPinAdd
)
t
.
Run
(
"TestPinAdd"
,
tp
.
TestPinAdd
)
t
.
Run
(
"TestPinSimple"
,
tp
.
TestPinSimple
)
t
.
Run
(
"TestPinSimple"
,
tp
.
TestPinSimple
)
t
.
Run
(
"TestPinRecursive"
,
tp
.
TestPinRecursive
)
t
.
Run
(
"TestPinRecursive"
,
tp
.
TestPinRecursive
)
...
...
core/coreapi/interface/tests/pubsub.go
浏览文件 @
e53dab86
...
@@ -2,12 +2,20 @@ package tests
...
@@ -2,12 +2,20 @@ package tests
import
(
import
(
"context"
"context"
"github.com/ipfs/go-ipfs/core/coreapi/interface"
"github.com/ipfs/go-ipfs/core/coreapi/interface/options"
"github.com/ipfs/go-ipfs/core/coreapi/interface/options"
"testing"
"testing"
"time"
"time"
)
)
func
(
tp
*
provider
)
TestPubSub
(
t
*
testing
.
T
)
{
func
(
tp
*
provider
)
TestPubSub
(
t
*
testing
.
T
)
{
tp
.
hasApi
(
t
,
func
(
api
iface
.
CoreAPI
)
error
{
if
api
.
PubSub
()
==
nil
{
return
apiNotImplemented
}
return
nil
})
t
.
Run
(
"TestBasicPubSub"
,
tp
.
TestBasicPubSub
)
t
.
Run
(
"TestBasicPubSub"
,
tp
.
TestBasicPubSub
)
}
}
...
...
core/coreapi/interface/tests/unixfs.go
浏览文件 @
e53dab86
...
@@ -24,6 +24,13 @@ import (
...
@@ -24,6 +24,13 @@ import (
)
)
func
(
tp
*
provider
)
TestUnixfs
(
t
*
testing
.
T
)
{
func
(
tp
*
provider
)
TestUnixfs
(
t
*
testing
.
T
)
{
tp
.
hasApi
(
t
,
func
(
api
coreiface
.
CoreAPI
)
error
{
if
api
.
Unixfs
()
==
nil
{
return
apiNotImplemented
}
return
nil
})
t
.
Run
(
"TestAdd"
,
tp
.
TestAdd
)
t
.
Run
(
"TestAdd"
,
tp
.
TestAdd
)
t
.
Run
(
"TestAddPinned"
,
tp
.
TestAddPinned
)
t
.
Run
(
"TestAddPinned"
,
tp
.
TestAddPinned
)
t
.
Run
(
"TestAddHashOnly"
,
tp
.
TestAddHashOnly
)
t
.
Run
(
"TestAddHashOnly"
,
tp
.
TestAddHashOnly
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论