Example #1
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")
}
Example #2
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")
}