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