4
5
. "launchpad.net/gocheck"
11
14
func Test(t *testing.T) { TestingT(t) }
16
type ConfigSuite struct{}
18
var _ = Suite(&ConfigSuite{})
20
var lxcfile = `# MIRROR to be used by ubuntu template at container creation:
21
# Leaving it undefined is fine
22
#MIRROR="http://archive.ubuntu.com/ubuntu"
24
#MIRROR="http://<host-ip-addr>:3142/archive.ubuntu.com/ubuntu"
26
# LXC_AUTO - whether or not to start containers symlinked under
30
# Leave USE_LXC_BRIDGE as "true" if you want to use lxcbr0 for your
31
# containers. Set to "false" if you'll use virbr0 or another existing
32
# bridge, or mavlan to your host's NIC.
35
# LXC_BRIDGE and LXC_ADDR are changed against original for
41
LXC_NETMASK="255.255.255.0"
42
LXC_NETWORK="10.0.9.0/24"
43
LXC_DHCP_RANGE="10.0.9.2,10.0.9.254"
45
# And for testing LXC_BRIDGE="lxcbr99" and LXC_ADDR="10.0.99.1".
47
LXC_SHUTDOWN_TIMEOUT=120`
49
var lxcconf = map[string]string{
50
"address": "10.0.9.1",
54
func (s *ConfigSuite) TestReadConf(c *C) {
55
// Test reading the configuration.
56
cf := filepath.Join(c.MkDir(), "lxc-test")
57
c.Assert(ioutil.WriteFile(cf, []byte(lxcfile), 0555), IsNil)
59
defer golxc.SetConfPath(golxc.SetConfPath(cf))
61
conf, err := golxc.ReadConf()
63
c.Assert(conf, DeepEquals, lxcconf)
66
func (s *ConfigSuite) TestReadNotExistingDefaultEnviron(c *C) {
67
// Test reading a not existing environment.
68
defer golxc.SetConfPath(golxc.SetConfPath(filepath.Join(c.MkDir(), "foo")))
70
_, err := golxc.ReadConf()
71
c.Assert(err, ErrorMatches, "open .*: no such file or directory")
13
74
type LXCSuite struct{}
15
76
var _ = Suite(&LXCSuite{})