github.com/axw/juju@v0.0.0-20161005053422-4bd6544d08d4/container/kvm/testing/test.go (about)

     1  // Copyright 2013 Canonical Ltd.
     2  // Licensed under the AGPLv3, see LICENCE file for details.
     3  
     4  // Functions defined in this file should *ONLY* be used for testing.  These
     5  // functions are exported for testing purposes only, and shouldn't be called
     6  // from code that isn't in a test file.
     7  
     8  package testing
     9  
    10  import (
    11  	gc "gopkg.in/check.v1"
    12  
    13  	"github.com/juju/juju/container"
    14  	"github.com/juju/juju/container/kvm"
    15  	"github.com/juju/juju/container/kvm/mock"
    16  	"github.com/juju/juju/testing"
    17  )
    18  
    19  // TestSuite replaces the kvm factory that the manager uses with a mock
    20  // implementation.
    21  type TestSuite struct {
    22  	testing.BaseSuite
    23  	ContainerFactory mock.ContainerFactory
    24  	ContainerDir     string
    25  	RemovedDir       string
    26  }
    27  
    28  func (s *TestSuite) SetUpTest(c *gc.C) {
    29  	s.BaseSuite.SetUpTest(c)
    30  	s.ContainerDir = c.MkDir()
    31  	s.PatchValue(&container.ContainerDir, s.ContainerDir)
    32  	s.RemovedDir = c.MkDir()
    33  	s.PatchValue(&container.RemovedContainerDir, s.RemovedDir)
    34  	s.ContainerFactory = mock.MockFactory()
    35  	s.PatchValue(&kvm.KvmObjectFactory, s.ContainerFactory)
    36  }