1
// Copyright 2016 Canonical Ltd.
2
// Licensed under the AGPLv3, see LICENCE file for details.
4
package charmstore // import "gopkg.in/juju/charmstore.v5-unstable/internal/charmstore"
8
"gopkg.in/juju/charm.v6-unstable"
9
"gopkg.in/juju/charmrepo.v2-unstable/csclient/params"
10
"gopkg.in/macaroon-bakery.v1/bakery"
12
"gopkg.in/juju/charmstore.v5-unstable/internal/router"
13
"gopkg.in/juju/charmstore.v5-unstable/internal/storetesting"
16
type commonSuite struct {
17
storetesting.IsolatedMgoESSuite
21
// addRequiredCharms adds any charms required by the given
22
// bundle that are not already in the store.
23
func (s *commonSuite) addRequiredCharms(c *gc.C, bundle charm.Bundle) {
24
store := s.newStore(c, true)
26
addRequiredCharms(c, store, bundle)
29
func (s *commonSuite) newStore(c *gc.C, withElasticSearch bool) *Store {
31
if withElasticSearch {
32
si = &SearchIndex{s.ES, s.TestIndex}
34
p, err := NewPool(s.Session.DB("juju_test"), si, &bakery.NewServiceParams{}, ServerParams{})
35
c.Assert(err, gc.IsNil)
41
func addRequiredCharms(c *gc.C, store *Store, bundle charm.Bundle) {
42
for _, app := range bundle.Data().Applications {
43
u := charm.MustParseURL(app.Charm)
44
if _, err := store.FindBestEntity(u, params.NoChannel, nil); err == nil {
50
var rurl router.ResolvedURL
52
ch := storetesting.Charms.CharmDir(u.Name)
53
if len(ch.Meta().Series) == 0 && u.Series == "" {
54
rurl.URL.Series = "trusty"
57
rurl.URL.User = "charmers"
58
rurl.PromulgatedRevision = rurl.URL.Revision
60
rurl.PromulgatedRevision = -1
62
err := store.AddCharmWithArchive(&rurl, ch)
63
c.Assert(err, gc.IsNil)
64
err = store.Publish(&rurl, nil, params.StableChannel)
65
c.Assert(err, gc.IsNil)