Exemple #1
0
func TestLoad(t *testing.T) {

	reader := strings.NewReader(`{
	"Server": {
		"host": "test.dev",
		"port": 1234
	},
	"Channels": [
		"#foo",
		"#bar"
	],
	"Plugins": [
		"one",
		"two"
	]
}`)

	c := config.Container{}
	c.Load(reader)

	assert.Equal(t, "test.dev", c.Config.Server.Host)
	assert.Equal(t, 1234, c.Config.Server.Port)
	assert.Equal(t, []string{"#foo", "#bar"}, c.Config.Channels)
	assert.Equal(t, []string{"one", "two"}, c.Config.Plugins)

}
Exemple #2
0
func main() {

	_, err := flags.Parse(&opts)

	if err != nil {
		panic(err)
		os.Exit(1)
	}

	// Try and load our config
	configFile, err := os.Open(opts.Config)

	if err != nil {
		fmt.Errorf("Cannot load config file!")
		panic(err)
		os.Exit(2)
	}

	container := config.Container{}
	container.Load(configFile)

	fmt.Println(container.Config.Server.Host)
}