Ejemplo n.º 1
0
func TestMultiRead(t *testing.T) {
	f, err := os.Open("test_config2.json")
	defer f.Close()

	if err != nil {
		panic(err)
	}

	err = config.ReadFile("other", f)

	if err != nil {
		panic(err)
	}

	cases := []struct {
		key  string
		want interface{}
	}{
		{"three", float64(3)},
		{"four", "four"},
	}

	for _, c := range cases {
		got := config.From("other").Get(c.key)
		if got != c.want {
			t.Errorf("config[%q] == %v, want %v", c.key, got, c.want)
		}
	}
}
Ejemplo n.º 2
0
func init() {
	f, err := os.Open("test_config.json")
	defer f.Close()

	if err != nil {
		panic(err)
	}

	config.InitConfig()
	err = config.ReadFile("default", f)

	if err != nil {
		panic(err)
	}
}