Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-unixfs
Commits
5a41a2ac
Commit
5a41a2ac
authored
Sep 12, 2014
by
Juan Batiz-Benet
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #54 from jbenet/fix/config-test
fix(config) failing test
parents
256db0b5
2e512e81
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
27 additions
and
19 deletions
+27
-19
cmd/ipfs/init.go
cmd/ipfs/init.go
+1
-1
config/config.go
config/config.go
+1
-1
config/config_test.go
config/config_test.go
+12
-5
core/core_test.go
core/core_test.go
+9
-9
core/datastore.go
core/datastore.go
+4
-3
No files found.
cmd/ipfs/init.go
View file @
5a41a2ac
...
@@ -43,7 +43,7 @@ func initCmd(c *commander.Command, inp []string) error {
...
@@ -43,7 +43,7 @@ func initCmd(c *commander.Command, inp []string) error {
}
}
cfg
:=
new
(
config
.
Config
)
cfg
:=
new
(
config
.
Config
)
cfg
.
Datastore
=
new
(
config
.
Datastore
)
cfg
.
Datastore
=
config
.
Datastore
{}
dspath
,
err
:=
u
.
TildeExpansion
(
"~/.go-ipfs/datastore"
)
dspath
,
err
:=
u
.
TildeExpansion
(
"~/.go-ipfs/datastore"
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
...
...
config/config.go
View file @
5a41a2ac
...
@@ -30,7 +30,7 @@ type SavedPeer struct {
...
@@ -30,7 +30,7 @@ type SavedPeer struct {
// Config is used to load IPFS config files.
// Config is used to load IPFS config files.
type
Config
struct
{
type
Config
struct
{
Identity
*
Identity
Identity
*
Identity
Datastore
*
Datastore
Datastore
Datastore
Peers
[]
*
SavedPeer
Peers
[]
*
SavedPeer
}
}
...
...
config/config_test.go
View file @
5a41a2ac
package
config
package
config
import
(
import
(
"fmt"
"testing"
"testing"
)
)
func
TestConfig
(
t
*
testing
.
T
)
{
func
TestConfig
(
t
*
testing
.
T
)
{
const
filename
=
".ipfsconfig"
cfg
,
err
:=
Load
(
".ipfsconfig"
)
const
dsPath
=
"/path/to/datastore"
cfgWritten
:=
new
(
Config
)
cfgWritten
.
Datastore
.
Path
=
dsPath
err
:=
WriteConfigFile
(
filename
,
cfgWritten
)
if
err
!=
nil
{
t
.
Error
(
err
)
}
cfgRead
,
err
:=
Load
(
filename
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Error
(
err
)
t
.
Error
(
err
)
return
return
}
}
if
cfgWritten
.
Datastore
.
Path
!=
cfgRead
.
Datastore
.
Path
{
fmt
.
Printf
(
cfg
.
Datastore
.
Path
)
t
.
Fail
()
}
}
}
core/core_test.go
View file @
5a41a2ac
...
@@ -7,23 +7,23 @@ import (
...
@@ -7,23 +7,23 @@ import (
)
)
func
TestInitialization
(
t
*
testing
.
T
)
{
func
TestInitialization
(
t
*
testing
.
T
)
{
id
:=
&
config
.
Identity
{
id
:=
&
config
.
Identity
{
PeerID
:
"QmNgdzLieYi8tgfo2WfTUzNVH5hQK9oAYGVf6dxN12NrHt"
,
PeerID
:
"QmNgdzLieYi8tgfo2WfTUzNVH5hQK9oAYGVf6dxN12NrHt"
,
Address
:
"/ip4/127.0.0.1/tcp/8000"
,
Address
:
"/ip4/127.0.0.1/tcp/8000"
,
PrivKey
:
"CAASrRIwggkpAgEAAoICAQCwt67GTUQ8nlJhks6CgbLKOx7F5tl1r9zF4m3TUrG3Pe8h64vi+ILDRFd7QJxaJ/n8ux9RUDoxLjzftL4uTdtv5UXl2vaufCc/C0bhCRvDhuWPhVsD75/DZPbwLsepxocwVWTyq7/ZHsCfuWdoh/KNczfy+Gn33gVQbHCnip/uhTVxT7ARTiv8Qa3d7qmmxsR+1zdL/IRO0mic/iojcb3Oc/PRnYBTiAZFbZdUEit/99tnfSjMDg02wRayZaT5ikxa6gBTMZ16Yvienq7RwSELzMQq2jFA4i/TdiGhS9uKywltiN2LrNDBcQJSN02pK12DKoi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mDPStnPsHAaIWOtni47zIgilJzD0WEk78/YjmPbUrboYvWziK5JiRRJFA1rkQqV1c0M+OXixIm+/yS8AksgCeaHr0WUieGcJtjT9uE8vyFop5ykhRiNxy9wGaq6i7IEecsrkd6DqxDHWkwhFuO1bSE83q/VAoIBAEA+RX1i/SUi08p71ggUi9WFMqXmzELp1L3hiEjOc2AklHk2rPxsaTh9+G95BvjhP7fRa/Yga+yDtYuyjO99nedStdNNSg03aPXILl9gs3r2dPiQKUEXZJ3FrH6tkils/8BlpOIRfbkszrdZIKTO9GCdLWQ30dQITDACs8zV/1GFGrHFrqnnMe/NpIFHWNZJ0/WZMi8wgWO6Ik8jHEpQtVXRiXLqy7U6hk170pa4GHOzvftfPElOZZjy9qn7KjdAQqy6spIrAE94OEL+fBgbHQZGLpuTlj6w6YGbMtPU8uo7sXKoc6WOCb68JWft3tejGLDa1946HAWqVM9B/UcneNc="
,
}
}
good
:=
[]
*
config
.
Config
{
good
:=
[]
*
config
.
Config
{
&
config
.
Config
{
&
config
.
Config
{
Identity
:
id
,
Identity
:
id
,
Datastore
:
&
config
.
Datastore
{
Datastore
:
config
.
Datastore
{
Type
:
"memory"
,
Type
:
"memory"
,
},
},
},
},
&
config
.
Config
{
&
config
.
Config
{
Identity
:
id
,
Identity
:
id
,
Datastore
:
&
config
.
Datastore
{
Datastore
:
config
.
Datastore
{
Type
:
"leveldb"
,
Type
:
"leveldb"
,
Path
:
".testdb"
,
Path
:
".testdb"
,
},
},
...
@@ -31,10 +31,10 @@ func TestInitialization(t *testing.T) {
...
@@ -31,10 +31,10 @@ func TestInitialization(t *testing.T) {
}
}
bad
:=
[]
*
config
.
Config
{
bad
:=
[]
*
config
.
Config
{
&
config
.
Config
{
Identity
:
id
,
Datastore
:
&
config
.
Datastore
{}},
&
config
.
Config
{
Identity
:
id
,
Datastore
:
config
.
Datastore
{}},
&
config
.
Config
{
Identity
:
id
,
Datastore
:
&
config
.
Datastore
{
Type
:
"badtype"
}},
&
config
.
Config
{
Identity
:
id
,
Datastore
:
config
.
Datastore
{
Type
:
"badtype"
}},
&
config
.
Config
{},
&
config
.
Config
{},
&
config
.
Config
{
Datastore
:
&
config
.
Datastore
{
Type
:
"memory"
}},
&
config
.
Config
{
Datastore
:
config
.
Datastore
{
Type
:
"memory"
}},
nil
,
nil
,
}
}
...
...
core/datastore.go
View file @
5a41a2ac
...
@@ -2,13 +2,14 @@ package core
...
@@ -2,13 +2,14 @@ package core
import
(
import
(
"fmt"
"fmt"
ds
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/datastore.go"
ds
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/datastore.go"
lds
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/datastore.go/leveldb"
lds
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/datastore.go/leveldb"
config
"github.com/jbenet/go-ipfs/config"
config
"github.com/jbenet/go-ipfs/config"
)
)
func
makeDatastore
(
cfg
*
config
.
Datastore
)
(
ds
.
Datastore
,
error
)
{
func
makeDatastore
(
cfg
config
.
Datastore
)
(
ds
.
Datastore
,
error
)
{
if
cfg
==
nil
||
len
(
cfg
.
Type
)
==
0
{
if
len
(
cfg
.
Type
)
==
0
{
return
nil
,
fmt
.
Errorf
(
"config datastore.type required"
)
return
nil
,
fmt
.
Errorf
(
"config datastore.type required"
)
}
}
...
@@ -22,7 +23,7 @@ func makeDatastore(cfg *config.Datastore) (ds.Datastore, error) {
...
@@ -22,7 +23,7 @@ func makeDatastore(cfg *config.Datastore) (ds.Datastore, error) {
return
nil
,
fmt
.
Errorf
(
"Unknown datastore type: %s"
,
cfg
.
Type
)
return
nil
,
fmt
.
Errorf
(
"Unknown datastore type: %s"
,
cfg
.
Type
)
}
}
func
makeLevelDBDatastore
(
cfg
*
config
.
Datastore
)
(
ds
.
Datastore
,
error
)
{
func
makeLevelDBDatastore
(
cfg
config
.
Datastore
)
(
ds
.
Datastore
,
error
)
{
if
len
(
cfg
.
Path
)
==
0
{
if
len
(
cfg
.
Path
)
==
0
{
return
nil
,
fmt
.
Errorf
(
"config datastore.path required for leveldb"
)
return
nil
,
fmt
.
Errorf
(
"config datastore.path required for leveldb"
)
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment