LEFT | RIGHT |
1 package state_test | 1 package state_test |
2 | 2 |
3 import ( | 3 import ( |
4 "fmt" | |
5 "labix.org/v2/mgo" | 4 "labix.org/v2/mgo" |
6 . "launchpad.net/gocheck" | 5 . "launchpad.net/gocheck" |
7 "launchpad.net/juju-core/charm" | |
8 "launchpad.net/juju-core/state" | 6 "launchpad.net/juju-core/state" |
9 "launchpad.net/juju-core/testing" | 7 "launchpad.net/juju-core/testing" |
10 "net/url" | |
11 stdtesting "testing" | 8 stdtesting "testing" |
12 ) | 9 ) |
13 | 10 |
14 // TestPackage integrates the tests into gotest. | 11 // TestPackage integrates the tests into gotest. |
15 func TestPackage(t *stdtesting.T) { | 12 func TestPackage(t *stdtesting.T) { |
16 testing.MgoTestPackage(t) | 13 testing.MgoTestPackage(t) |
17 } | 14 } |
18 | 15 |
19 // ConnSuite provides the infrastructure for all other | 16 // ConnSuite provides the infrastructure for all other |
20 // test suites (StateSuite, CharmSuite, MachineSuite, etc). | 17 // test suites (StateSuite, CharmSuite, MachineSuite, etc). |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 c.Assert(err, IsNil) | 51 c.Assert(err, IsNil) |
55 } | 52 } |
56 | 53 |
57 func (cs *ConnSuite) TearDownTest(c *C) { | 54 func (cs *ConnSuite) TearDownTest(c *C) { |
58 cs.State.Close() | 55 cs.State.Close() |
59 cs.MgoSuite.TearDownTest(c) | 56 cs.MgoSuite.TearDownTest(c) |
60 cs.LoggingSuite.TearDownTest(c) | 57 cs.LoggingSuite.TearDownTest(c) |
61 } | 58 } |
62 | 59 |
63 func (s *ConnSuite) AddTestingCharm(c *C, name string) *state.Charm { | 60 func (s *ConnSuite) AddTestingCharm(c *C, name string) *state.Charm { |
64 » ch := testing.Charms.Dir(name) | 61 » return s.State.AddTestingCharm(c, name) |
65 » ident := fmt.Sprintf("%s-%d", name, ch.Revision()) | |
66 » curl := charm.MustParseURL("local:series/" + ident) | |
67 » bundleURL, err := url.Parse("http://bundles.example.com/" + ident) | |
68 » c.Assert(err, IsNil) | |
69 » sch, err := s.State.AddCharm(ch, curl, bundleURL, ident+"-sha256") | |
70 » c.Assert(err, IsNil) | |
71 » return sch | |
72 } | 62 } |
| 63 |
| 64 // AddConfigCharm clones a testing charm, replaces its config with |
| 65 // the given YAML string and adds it to the state, using the given |
| 66 // revision. |
| 67 func (s *ConnSuite) AddConfigCharm(c *C, name, configYaml string, revision int)
*state.Charm { |
| 68 return s.State.AddConfigCharm(c, name, configYaml, revision) |
| 69 } |
LEFT | RIGHT |