OLD | NEW |
(Empty) | |
| 1 package golxc_test |
| 2 |
| 3 import ( |
| 4 . "launchpad.net/gocheck" |
| 5 "launchpad.net/golxc" |
| 6 "strings" |
| 7 "testing" |
| 8 ) |
| 9 |
| 10 func Test(t *testing.T) { TestingT(t) } |
| 11 |
| 12 type ConfigurationSuite struct{} |
| 13 |
| 14 var _ = Suite(&ConfigurationSuite{}) |
| 15 |
| 16 var cfgs = `# Leading commment. |
| 17 VALUE1 = 12345 |
| 18 VALUE2="foo" |
| 19 VALUE3 = "foo # bar" |
| 20 VALUE4 = "foo = bar" |
| 21 VALUE5 = "bar" # Trailing comment. |
| 22 VALUE6 = bar # foo |
| 23 |
| 24 # Comment inbetween. |
| 25 |
| 26 VALUE7 = |
| 27 VALUE8 = ""` |
| 28 |
| 29 func (s *ConfigurationSuite) TestReadConfiguration(c *C) { |
| 30 cr := strings.NewReader(cfgs) |
| 31 cfg, err := golxc.ReadConfiguration(cr) |
| 32 c.Assert(err, IsNil) |
| 33 c.Assert(len(cfg), Equals, 8) |
| 34 c.Assert(cfg["VALUE1"], Equals, "12345") |
| 35 c.Assert(cfg["VALUE2"], Equals, "foo") |
| 36 c.Assert(cfg["VALUE3"], Equals, "foo # bar") |
| 37 c.Assert(cfg["VALUE4"], Equals, "foo = bar") |
| 38 c.Assert(cfg["VALUE5"], Equals, "bar") |
| 39 c.Assert(cfg["VALUE6"], Equals, "bar") |
| 40 c.Assert(cfg["VALUE7"], Equals, "") |
| 41 c.Assert(cfg["VALUE8"], Equals, "") |
| 42 } |
| 43 |
| 44 func (s *ConfigurationSuite) TestReadDefaultEnvironment(c *C) { |
| 45 env, err := golxc.ReadDefaultEnvironment() |
| 46 c.Assert(err, IsNil) |
| 47 c.Assert(env["LXC_BRIDGE"], Equals, "lxcbr0") |
| 48 } |
OLD | NEW |