-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinternal_test.go
63 lines (53 loc) · 1.59 KB
/
internal_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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// Copyright 2015 Canonical Ltd.
// Licensed under the AGPLv3, see LICENCE file for details.
package state
import (
"github.com/juju/names"
jujutesting "github.com/juju/testing"
jc "github.com/juju/testing/checkers"
gc "gopkg.in/check.v1"
"github.com/juju/juju/mongo"
"github.com/juju/juju/testing"
)
var _ = gc.Suite(&internalStateSuite{})
// internalStateSuite manages a *State instance for tests in the state
// package (i.e. internal tests) that need it. It is similar to
// state.testing.StateSuite but is duplicated to avoid cyclic imports.
type internalStateSuite struct {
jujutesting.MgoSuite
testing.BaseSuite
state *State
owner names.UserTag
}
func (s *internalStateSuite) SetUpSuite(c *gc.C) {
s.MgoSuite.SetUpSuite(c)
s.BaseSuite.SetUpSuite(c)
}
func (s *internalStateSuite) TearDownSuite(c *gc.C) {
s.BaseSuite.TearDownSuite(c)
s.MgoSuite.TearDownSuite(c)
}
func (s *internalStateSuite) SetUpTest(c *gc.C) {
s.MgoSuite.SetUpTest(c)
s.BaseSuite.SetUpTest(c)
s.owner = names.NewLocalUserTag("test-admin")
// Copied from NewMongoInfo (due to import loops).
info := &mongo.MongoInfo{
Info: mongo.Info{
Addrs: []string{jujutesting.MgoServer.Addr()},
CACert: testing.CACert,
},
}
// Copied from NewDialOpts (due to import loops).
dialopts := mongo.DialOpts{
Timeout: testing.LongWait,
}
st, err := Initialize(s.owner, info, testing.EnvironConfig(c), dialopts, nil)
c.Assert(err, jc.ErrorIsNil)
s.state = st
s.AddCleanup(func(*gc.C) { s.state.Close() })
}
func (s *internalStateSuite) TearDownTest(c *gc.C) {
s.BaseSuite.TearDownTest(c)
s.MgoSuite.TearDownTest(c)
}