Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
19ca1a81
提交
19ca1a81
authored
1月 14, 2019
作者:
Łukasz Magiera
提交者:
Steven Allen
1月 23, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Unixfs.Add nocopy test
License: MIT Signed-off-by:
Łukasz Magiera
<
magik6k@gmail.com
>
上级
649fd1f4
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
53 行增加
和
3 行删除
+53
-3
unixfs.go
core/coreapi/interface/tests/unixfs.go
+42
-0
api_test.go
core/coreapi/test/api_test.go
+9
-2
mock.go
repo/mock.go
+2
-1
没有找到文件。
core/coreapi/interface/tests/unixfs.go
浏览文件 @
19ca1a81
...
...
@@ -101,6 +101,34 @@ func (tp *provider) TestAdd(t *testing.T) {
return
coreiface
.
IpfsPath
(
c
)
}
rf
,
err
:=
ioutil
.
TempFile
(
os
.
TempDir
(),
"unixfs-add-real"
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
rfp
:=
rf
.
Name
()
if
_
,
err
:=
rf
.
Write
([]
byte
(
helloStr
));
err
!=
nil
{
t
.
Fatal
(
err
)
}
stat
,
err
:=
rf
.
Stat
()
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
if
err
:=
rf
.
Close
();
err
!=
nil
{
t
.
Fatal
(
err
)
}
defer
os
.
Remove
(
rfp
)
realFile
:=
func
()
files
.
Node
{
n
,
err
:=
files
.
NewReaderPathFile
(
rfp
,
ioutil
.
NopCloser
(
strings
.
NewReader
(
helloStr
)),
stat
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
return
n
}
cases
:=
[]
struct
{
name
string
data
func
()
files
.
Node
...
...
@@ -323,6 +351,20 @@ func (tp *provider) TestAdd(t *testing.T) {
path
:
"/ipfs/QmRKGpFfR32FVXdvJiHfo4WJ5TDYBsM1P9raAp1p6APWSp"
,
opts
:
[]
options
.
UnixfsAddOption
{
options
.
Unixfs
.
Hidden
(
false
)},
},
// NoCopy
{
name
:
"simpleNoCopy"
,
data
:
realFile
,
path
:
"/ipfs/zb2rhdhmJjJZs9qkhQCpCQ7VREFkqWw3h1r8utjVvQugwHPFd"
,
opts
:
[]
options
.
UnixfsAddOption
{
options
.
Unixfs
.
Nocopy
(
true
)},
},
{
name
:
"noCopyNoRaw"
,
data
:
realFile
,
path
:
"/ipfs/zb2rhdhmJjJZs9qkhQCpCQ7VREFkqWw3h1r8utjVvQugwHPFd"
,
opts
:
[]
options
.
UnixfsAddOption
{
options
.
Unixfs
.
Nocopy
(
true
),
options
.
Unixfs
.
RawLeaves
(
false
)},
err
:
"nocopy option requires '--raw-leaves' to be enabled as well"
,
},
// Events / Progress
{
name
:
"simpleAddEvent"
,
...
...
core/coreapi/test/api_test.go
浏览文件 @
19ca1a81
...
...
@@ -4,9 +4,13 @@ import (
"context"
"encoding/base64"
"fmt"
"github.com/ipfs/go-ipfs/core/coreapi/interface/tests"
"os"
"path/filepath"
"testing"
"github.com/ipfs/go-ipfs/core/coreapi/interface/tests"
"github.com/ipfs/go-ipfs/filestore"
"github.com/ipfs/go-ipfs/core"
"github.com/ipfs/go-ipfs/core/coreapi"
coreiface
"github.com/ipfs/go-ipfs/core/coreapi/interface"
...
...
@@ -64,11 +68,14 @@ func (NodeProvider) MakeAPISwarm(ctx context.Context, fullIdentity bool, n int)
c
:=
config
.
Config
{}
c
.
Addresses
.
Swarm
=
[]
string
{
fmt
.
Sprintf
(
"/ip4/127.0.%d.1/tcp/4001"
,
i
)}
c
.
Identity
=
ident
c
.
Experimental
.
FilestoreEnabled
=
true
ds
:=
datastore
.
NewMapDatastore
()
r
:=
&
repo
.
Mock
{
C
:
c
,
D
:
syncds
.
MutexWrap
(
d
atastore
.
NewMapDatastore
()
),
D
:
syncds
.
MutexWrap
(
d
s
),
K
:
keystore
.
NewMemKeystore
(),
F
:
filestore
.
NewFileManager
(
ds
,
filepath
.
Dir
(
os
.
TempDir
())),
}
node
,
err
:=
core
.
NewNode
(
ctx
,
&
core
.
BuildCfg
{
...
...
repo/mock.go
浏览文件 @
19ca1a81
...
...
@@ -17,6 +17,7 @@ type Mock struct {
C
config
.
Config
D
Datastore
K
keystore
.
Keystore
F
*
filestore
.
FileManager
}
func
(
m
*
Mock
)
Config
()
(
*
config
.
Config
,
error
)
{
...
...
@@ -54,4 +55,4 @@ func (m *Mock) SwarmKey() ([]byte, error) {
return
nil
,
nil
}
func
(
m
*
Mock
)
FileManager
()
*
filestore
.
FileManager
{
return
nil
}
func
(
m
*
Mock
)
FileManager
()
*
filestore
.
FileManager
{
return
m
.
F
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论