another type check fix and add back a missing test
License: MIT Signed-off-by: Jeromy <why@ipfs.io>
Jeromy committed
Jul 15, 2016 at 10:49 UTC
72705564e76180cdad020b580574bfbc3b799753
2 files changed
+11
-1
core/commands/config.go
+7
-1
@@ -290,7 +290,13 @@ func replaceConfig(r repo.Repo, file io.Reader) error {
290
if err != nil {
291
return fmt.Errorf("Failed to get PrivKey")
292
}
293
- cfg.Identity.PrivKey = keyF.Value.(string)
293
+
294
+ pkstr, ok := keyF.Value.(string)
295
+ if !ok {
296
+ return fmt.Errorf("private key in config was not a string")
297
+ }
298
+
299
+ cfg.Identity.PrivKey = pkstr
300
301
return r.SetConfig(&cfg)
302
}
test/sharness/t0021-config.sh
+4
@@ -87,6 +87,10 @@ test_config_cmd() {
87
test_expect_code 1 ipfs config Identity.PrivKey 2> ident_out
88
'
89
90
+ test_expect_success "output looks good" '
91
+ test_cmp ident_exp ident_out
92
+ '
93
+
94
test_expect_success "lower cased PrivKey" '
95
sed -i -e '\''s/PrivKey/privkey/'\'' "$IPFS_PATH/config" &&
96
test_expect_code 1 ipfs config Identity.privkey 2> ident_out