Example #1
0
func (s *BundleSuite) TestReadBundleBytes(c *gc.C) {
	data, err := ioutil.ReadFile(s.bundlePath)
	c.Assert(err, gc.IsNil)

	bundle, err := charm.ReadBundleBytes(data)
	c.Assert(err, gc.IsNil)
	checkDummy(c, bundle, "")
}
Example #2
0
func bundleDir(c *gc.C, dirpath string) *charm.Bundle {
	dir, err := charm.ReadDir(dirpath)
	c.Assert(err, gc.IsNil)
	buf := new(bytes.Buffer)
	err = dir.BundleTo(buf)
	c.Assert(err, gc.IsNil)
	bundle, err := charm.ReadBundleBytes(buf.Bytes())
	c.Assert(err, gc.IsNil)
	return bundle
}
Example #3
0
func (s *StoreSuite) TestCharmPublisher(c *gc.C) {
	urlA := charm.MustParseURL("cs:oneiric/wordpress-a")
	urlB := charm.MustParseURL("cs:oneiric/wordpress-b")
	urls := []*charm.URL{urlA, urlB}

	pub, err := s.store.CharmPublisher(urls, "some-digest")
	c.Assert(err, gc.IsNil)
	c.Assert(pub.Revision(), gc.Equals, 0)

	err = pub.Publish(testing.Charms.ClonedDir(c.MkDir(), "dummy"))
	c.Assert(err, gc.IsNil)

	for _, url := range urls {
		info, rc, err := s.store.OpenCharm(url)
		c.Assert(err, gc.IsNil)
		c.Assert(info.Revision(), gc.Equals, 0)
		c.Assert(info.Digest(), gc.Equals, "some-digest")
		data, err := ioutil.ReadAll(rc)
		c.Check(err, gc.IsNil)
		err = rc.Close()
		c.Assert(err, gc.IsNil)
		bundle, err := charm.ReadBundleBytes(data)
		c.Assert(err, gc.IsNil)

		// The same information must be available by reading the
		// full charm data...
		c.Assert(bundle.Meta().Name, gc.Equals, "dummy")
		c.Assert(bundle.Config().Options["title"].Default, gc.Equals, "My Title")

		// ... and the queriable details.
		c.Assert(info.Meta().Name, gc.Equals, "dummy")
		c.Assert(info.Config().Options["title"].Default, gc.Equals, "My Title")

		info2, err := s.store.CharmInfo(url)
		c.Assert(err, gc.IsNil)
		c.Assert(info2, gc.DeepEquals, info)
	}
}