Ejemplo n.º 1
0
func (s *ConfigSuite) TestReadNotExistingDefaultEnvironment(c *C) {
	// Test reading a not existing environment.
	defer golxc.SetConfPath(golxc.SetConfPath(filepath.Join(c.MkDir(), "foo")))

	_, err := golxc.ReadConf()
	c.Assert(err, ErrorMatches, "open .*: no such file or directory")
}
Ejemplo n.º 2
0
func (s *NetworkSuite) TestNotExistingNetworkAttributes(c *C) {
	// Test reading of network attributes from a not existing environment.
	defer golxc.SetConfPath(golxc.SetConfPath(filepath.Join(c.MkDir(), "foo")))

	_, _, err := golxc.NetworkAttributes()
	c.Assert(err, ErrorMatches, "open .*: no such file or directory")
}
Ejemplo n.º 3
0
func (s *ConfigSuite) TestReadConf(c *C) {
	// Test reading the configuration.
	cf := filepath.Join(c.MkDir(), "lxc-test")
	c.Assert(ioutil.WriteFile(cf, []byte(lxcfile), 0555), IsNil)

	defer golxc.SetConfPath(golxc.SetConfPath(cf))

	conf, err := golxc.ReadConf()
	c.Assert(err, IsNil)
	c.Assert(conf, DeepEquals, lxcconf)
}
Ejemplo n.º 4
0
func (s *ConfigSuite) TestNetworkAttributes(c *C) {
	// Test reading the network attribute form an environment.
	cf := filepath.Join(c.MkDir(), "lxc-test")
	c.Assert(ioutil.WriteFile(cf, []byte(lxcfile), 0555), IsNil)

	defer golxc.SetConfPath(golxc.SetConfPath(cf))

	addr, bridge, err := golxc.NetworkAttributes()
	c.Assert(err, IsNil)
	c.Assert(addr, Equals, "10.0.9.1")
	c.Assert(bridge, Equals, "lxcbr9")
}