263.8.9
by Aram Hăvărneanu
mstate: port charm_test.go from state. |
1 |
package mstate_test |
2 |
||
3 |
import ( |
|
4 |
. "launchpad.net/gocheck" |
|
5 |
"launchpad.net/juju-core/charm"
|
|
6 |
"net/url"
|
|
7 |
)
|
|
8 |
||
9 |
type CharmSuite struct { |
|
10 |
UtilSuite
|
|
11 |
curl *charm.URL |
|
12 |
}
|
|
13 |
||
14 |
var _ = Suite(&CharmSuite{}) |
|
15 |
||
16 |
func (s *CharmSuite) SetUpTest(c *C) { |
|
17 |
s.UtilSuite.SetUpTest(c) |
|
18 |
added := s.AddTestingCharm(c, "dummy") |
|
19 |
s.curl = added.URL() |
|
20 |
}
|
|
21 |
||
22 |
func (s *CharmSuite) TestCharm(c *C) { |
|
23 |
dummy, err := s.State.Charm(s.curl) |
|
24 |
c.Assert(err, IsNil) |
|
25 |
c.Assert(dummy.URL().String(), Equals, s.curl.String()) |
|
26 |
c.Assert(dummy.Revision(), Equals, 1) |
|
27 |
bundleURL, err := url.Parse("http://bundles.example.com/dummy-1") |
|
28 |
c.Assert(err, IsNil) |
|
29 |
c.Assert(dummy.BundleURL(), DeepEquals, bundleURL) |
|
30 |
c.Assert(dummy.BundleSha256(), Equals, "dummy-1-sha256") |
|
31 |
meta := dummy.Meta() |
|
32 |
c.Assert(meta.Name, Equals, "dummy") |
|
33 |
config := dummy.Config() |
|
34 |
c.Assert(config.Options["title"], Equals, |
|
35 |
charm.Option{ |
|
36 |
Default: "My Title", |
|
37 |
Description: "A descriptive title used for the service.", |
|
38 |
Type: "string", |
|
39 |
},
|
|
40 |
)
|
|
263.8.12
by Aram Hăvărneanu
mstate: go fmt. |
41 |
}
|
263.8.14
by Aram Hăvărneanu
mstate: more tests. |
42 |
|
43 |
func (s *CharmSuite) TestGetNonExistentCharm(c *C) { |
|
44 |
// Check that getting a non-existent charm fails nicely.
|
|
45 |
||
46 |
curl := charm.MustParseURL("local:anotherseries/dummy-1") |
|
47 |
_, err := s.State.Charm(curl) |
|
48 |
c.Assert(err, ErrorMatches, `can't get charm "local:anotherseries/dummy-1": .*`) |
|
49 |
}
|