github.com/cloudbase/juju-core@v0.0.0-20140504232958-a7271ac7912f/provider/local/lxc_test.go (about) 1 // Copyright 2014 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 package local_test 5 6 import ( 7 gc "launchpad.net/gocheck" 8 9 "launchpad.net/juju-core/instance" 10 "launchpad.net/juju-core/provider/local" 11 jc "launchpad.net/juju-core/testing/checkers" 12 "launchpad.net/juju-core/testing/testbase" 13 ) 14 15 type lxcTest struct { 16 testbase.LoggingSuite 17 } 18 19 var _ = gc.Suite(&lxcTest{}) 20 21 func (*lxcTest) TestUseFastLXCForContainer(c *gc.C) { 22 c.Assert(local.UseFastLXC(instance.ContainerType("")), jc.IsFalse) 23 c.Assert(local.UseFastLXC(instance.KVM), jc.IsFalse) 24 } 25 26 func (t *lxcTest) TestUseFastLXC(c *gc.C) { 27 for i, test := range []struct { 28 message string 29 releaseVersion string 30 expected bool 31 overrideSlow string 32 }{{ 33 message: "missing release file", 34 }, { 35 message: "precise release", 36 releaseVersion: "12.04", 37 }, { 38 message: "trusty release", 39 releaseVersion: "14.04", 40 expected: true, 41 }, { 42 message: "unstable unicorn", 43 releaseVersion: "14.10", 44 expected: true, 45 }, { 46 message: "jaunty", 47 releaseVersion: "9.10", 48 }, { 49 message: "env override", 50 releaseVersion: "14.04", 51 overrideSlow: "value", 52 }} { 53 c.Logf("%v: %v", i, test.message) 54 t.PatchValue(local.ReleaseVersion, func() string { return test.releaseVersion }) 55 t.PatchEnvironment(local.EnvKeyTestingForceSlow, test.overrideSlow) 56 value := local.UseFastLXC(instance.LXC) 57 c.Assert(value, gc.Equals, test.expected) 58 } 59 }