/usr/share/gocode/src/github.com/tendermint/go-config/config_test.go is in golang-github-tendermint-go-config-dev 0.0~git20160626.0.e64b424-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | package config
import (
"testing"
"github.com/BurntSushi/toml"
. "github.com/tendermint/go-common"
)
var (
stringTable = map[string]string{
"astring": "a",
"subfield1.astring": "b",
"subfield1.subsub.astring": "b",
"subfield2.astring": "c",
}
intTable = map[string]int{
"anint": 42,
}
boolTable = map[string]bool{
"abool": false,
}
)
var testTxt = Fmt(`
# This is a TOML config file.
# For more information, see https://github.com/toml-lang/toml
astring = "%s"
anint = %d
abool = %v
[subfield1]
astring = "%s"
[subfield1.subsub]
astring = "%s"
[subfield2]
astring = "%s"
`, stringTable["astring"], intTable["anint"], boolTable["abool"], stringTable["subfield1.astring"],
stringTable["subfield1.subsub.astring"],
stringTable["subfield2.astring"])
func TestConfig(t *testing.T) {
var configData = make(map[string]interface{})
err := toml.Unmarshal([]byte(testTxt), &configData)
if err != nil {
t.Fatal(err)
}
cfg := NewMapConfig(configData)
for k, v := range stringTable {
if x := cfg.GetString(k); x != v {
t.Fatalf("Got %v. Expected %v", x, v)
}
}
for k, v := range intTable {
if x := cfg.GetInt(k); x != v {
t.Fatalf("Got %v. Expected %v", x, v)
}
}
for k, v := range boolTable {
if x := cfg.GetBool(k); x != v {
t.Fatalf("Got %v. Expected %v", x, v)
}
}
}
func TestSetConfig(t *testing.T) {
var configData = make(map[string]interface{})
cfg := NewMapConfig(configData)
cfg.Set("abc.def", "x")
if x := cfg.GetString("abc.def"); x != "x" {
t.Fatalf("Got %v, expected 1", x)
}
}
|