github.com/mhilton/juju-juju@v0.0.0-20150901100907-a94dd2c73455/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 "gopkg.in/check.v1"
     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  	ContainerFactory 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  	c.Logf("container.ContainerDir = %q", s.ContainerDir)
    31  	s.RemovedDir = c.MkDir()
    32  	s.PatchValue(&container.RemovedContainerDir, s.RemovedDir)
    33  	c.Logf("container.RemovedContainerDir = %q", s.RemovedDir)
    34  	s.LxcDir = c.MkDir()
    35  	s.PatchValue(&lxc.LxcContainerDir, s.LxcDir)
    36  	c.Logf("lxc.LxcContainerDir = %q", s.LxcDir)
    37  	s.RestartDir = c.MkDir()
    38  	s.PatchValue(&lxc.LxcRestartDir, s.RestartDir)
    39  	c.Logf("lxc.LxcRestartDir = %q", s.RestartDir)
    40  	s.ContainerFactory = mock.MockFactory(s.LxcDir)
    41  	s.PatchValue(&lxc.LxcObjectFactory, s.ContainerFactory)
    42  	c.Logf("lxc.LxcObjectFactory dir = %q", s.LxcDir)
    43  }