github.com/mattyw/juju@v0.0.0-20140610034352-732aecd63861/container/lxc/testing/test.go (about)

     1  // Copyright 2013 Canonical Ltd.
     2  // Licensed under the AGPLv3, see LICENCE file for details.
     3  
     4  package testing
     5  
     6  import (
     7  	gc "launchpad.net/gocheck"
     8  
     9  	"github.com/juju/juju/container"
    10  	"github.com/juju/juju/container/lxc"
    11  	"github.com/juju/juju/container/lxc/mock"
    12  	"github.com/juju/juju/testing"
    13  )
    14  
    15  // TestSuite replaces the lxc factory that the broker uses with a mock
    16  // implementation.
    17  type TestSuite struct {
    18  	testing.FakeJujuHomeSuite
    19  	Factory      mock.ContainerFactory
    20  	ContainerDir string
    21  	RemovedDir   string
    22  	LxcDir       string
    23  	RestartDir   string
    24  }
    25  
    26  func (s *TestSuite) SetUpTest(c *gc.C) {
    27  	s.FakeJujuHomeSuite.SetUpTest(c)
    28  	s.ContainerDir = c.MkDir()
    29  	s.PatchValue(&container.ContainerDir, s.ContainerDir)
    30  	s.RemovedDir = c.MkDir()
    31  	s.PatchValue(&container.RemovedContainerDir, s.RemovedDir)
    32  	s.LxcDir = c.MkDir()
    33  	s.PatchValue(&lxc.LxcContainerDir, s.LxcDir)
    34  	s.RestartDir = c.MkDir()
    35  	s.PatchValue(&lxc.LxcRestartDir, s.RestartDir)
    36  	s.Factory = mock.MockFactory(s.LxcDir)
    37  	s.PatchValue(&lxc.LxcObjectFactory, s.Factory)
    38  }