7
7
. "launchpad.net/gocheck"
8
8
"launchpad.net/goyaml"
9
9
"launchpad.net/juju/go/charm"
10
"launchpad.net/juju/go/testing"
13
func Test(t *testing.T) {
14
func Test(t *stdtesting.T) {
21
func (s *S) SetUpSuite(c *C) {}
18
type CharmSuite struct{}
20
var _ = Suite(&CharmSuite{})
22
func (s *CharmSuite) TestRead(c *C) {
23
bPath := testing.Charms.BundlePath(c.MkDir(), "dummy")
24
ch, err := charm.Read(bPath)
26
c.Assert(ch.Meta().Name, Equals, "dummy")
27
dPath := testing.Charms.DirPath("dummy")
28
ch, err = charm.Read(dPath)
30
c.Assert(ch.Meta().Name, Equals, "dummy")
33
var inferRepoTests = []struct {
39
{"wordpress", "precise", "anything", "cs:precise/wordpress"},
40
{"oneiric/wordpress", "anything", "anything", "cs:oneiric/wordpress"},
41
{"cs:oneiric/wordpress", "anything", "anything", "cs:oneiric/wordpress"},
42
{"local:wordpress", "precise", "/some/path", "local:precise/wordpress"},
43
{"local:oneiric/wordpress", "anything", "/some/path", "local:oneiric/wordpress"},
46
func (s *CharmSuite) TestInferRepository(c *C) {
47
for _, t := range inferRepoTests {
48
repo, curl, err := charm.InferRepository(t.name, t.series, t.path)
50
expectCurl := charm.MustParseURL(t.curl)
51
c.Assert(curl, DeepEquals, expectCurl)
52
if localRepo, ok := repo.(*charm.LocalRepository); ok {
53
c.Assert(localRepo.Path, Equals, t.path)
54
c.Assert(curl.Schema, Equals, "local")
56
c.Assert(curl.Schema, Equals, "cs")
59
_, _, err := charm.InferRepository("local:whatever", "series", "")
60
c.Assert(err, ErrorMatches, "path to local repository not specified")
23
63
func checkDummy(c *C, f charm.Charm, path string) {
24
64
c.Assert(f.Revision(), Equals, 1)