Skip to content

Commit

Permalink
Remove charmstore from application.DeployCharmStoreSuite
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim McNamara committed Apr 11, 2019
1 parent fba1f83 commit 9371ecd
Show file tree
Hide file tree
Showing 11 changed files with 623 additions and 54 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"gopkg.in/juju/charm.v6"
"gopkg.in/juju/charmrepo.v3"
"gopkg.in/juju/charmrepo.v3/csclient"
"gopkg.in/juju/charmrepo.v3/csclient/params"
"gopkg.in/juju/charmstore.v5"

"github.com/juju/juju/apiserver/facades/controller/charmrevisionupdater"
Expand All @@ -21,6 +22,15 @@ import (
"github.com/juju/juju/testcharms"
)

type charmSuiteClientShim struct {
*csclient.Client
}

func (c charmSuiteClientShim) WithChannel(channel params.Channel) testcharms.CharmstoreClient {
client := c.Client.WithChannel(channel)
return charmSuiteClientShim{client}
}

// CharmSuite provides infrastructure to set up and perform tests associated
// with charm versioning. A testing charm store server is created and populated
// with some known charms used for testing.
Expand Down Expand Up @@ -62,7 +72,8 @@ func (s *CharmSuite) SetUpTest(c *gc.C) {
"logging": "quantal/logging-27",
}
for name, url := range urls {
testcharms.UploadCharm(c, s.Client, url, name)
client := &charmSuiteClientShim{s.Client}
testcharms.UploadCharm(c, client, url, name)
}
s.jcSuite.PatchValue(&charmrepo.CacheDir, c.MkDir())
// Patch the charm repo initializer function: it is replaced with a charm
Expand Down
16 changes: 14 additions & 2 deletions apiserver/testing/fakecharmstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"gopkg.in/juju/charm.v6"
"gopkg.in/juju/charmrepo.v3"
"gopkg.in/juju/charmrepo.v3/csclient"
"gopkg.in/juju/charmrepo.v3/csclient/params"
"gopkg.in/juju/charmstore.v5"
"gopkg.in/macaroon-bakery.v2-unstable/bakery/checkers"
"gopkg.in/macaroon-bakery.v2-unstable/bakerytest"
Expand All @@ -22,6 +23,15 @@ import (
"github.com/juju/juju/testcharms"
)

type charmstoreClientShim struct {
*csclient.Client
}

func (c charmstoreClientShim) WithChannel(channel params.Channel) testcharms.CharmstoreClient {
client := c.Client.WithChannel(channel)
return charmstoreClientShim{client}
}

type CharmStoreSuite struct {
testing.CleanupSuite

Expand Down Expand Up @@ -77,9 +87,11 @@ func (s *CharmStoreSuite) TearDownTest(c *gc.C) {
}

func (s *CharmStoreSuite) UploadCharm(c *gc.C, url, name string) (*charm.URL, charm.Charm) {
return testcharms.UploadCharm(c, s.Client, url, name)
client := &charmstoreClientShim{s.Client}
return testcharms.UploadCharm(c, client, url, name)
}

func (s *CharmStoreSuite) UploadCharmMultiSeries(c *gc.C, url, name string) (*charm.URL, charm.Charm) {
return testcharms.UploadCharmMultiSeries(c, s.Client, url, name)
client := &charmstoreClientShim{s.Client}
return testcharms.UploadCharmMultiSeries(c, client, url, name)
}
Loading

0 comments on commit 9371ecd

Please sign in to comment.