~juju-qa/ubuntu/xenial/juju/xenial-2.0-beta3

« back to all changes in this revision

Viewing changes to src/github.com/juju/juju/cmd/juju/service/upgradecharm_test.go

  • Committer: Martin Packman
  • Date: 2016-03-30 19:31:08 UTC
  • mfrom: (1.1.41)
  • Revision ID: martin.packman@canonical.com-20160330193108-h9iz3ak334uk0z5r
Merge new upstream source 2.0~beta3

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
        "bytes"
8
8
        "fmt"
9
9
        "io/ioutil"
10
 
        "net/http"
11
10
        "net/http/httptest"
12
11
        "os"
13
12
        "path"
19
18
        gc "gopkg.in/check.v1"
20
19
        "gopkg.in/juju/charm.v6-unstable"
21
20
        "gopkg.in/juju/charmrepo.v2-unstable"
 
21
        "gopkg.in/juju/charmrepo.v2-unstable/csclient"
 
22
        csclientparams "gopkg.in/juju/charmrepo.v2-unstable/csclient/params"
22
23
        "gopkg.in/juju/charmstore.v5-unstable"
 
24
        "gopkg.in/macaroon-bakery.v1/httpbakery"
23
25
 
24
26
        "github.com/juju/juju/cmd/juju/common"
25
27
        "github.com/juju/juju/cmd/modelcmd"
42
44
        handler, err := charmstore.NewServer(s.Session.DB("juju-testing"), nil, "", charmstore.ServerParams{
43
45
                AuthUsername: "test-user",
44
46
                AuthPassword: "test-password",
45
 
        }, charmstore.V4)
 
47
        }, charmstore.V5)
46
48
        c.Assert(err, jc.ErrorIsNil)
47
49
        s.handler = handler
48
50
        s.srv = httptest.NewServer(handler)
49
51
 
50
52
        s.PatchValue(&charmrepo.CacheDir, c.MkDir())
51
 
        original := newCharmStoreClient
52
 
        s.PatchValue(&newCharmStoreClient, func(httpClient *http.Client) *csClient {
53
 
                csclient := original(httpClient)
54
 
                csclient.params.URL = s.srv.URL
55
 
                return csclient
 
53
        s.PatchValue(&newCharmStoreClient, func(bakeryClient *httpbakery.Client) *csclient.Client {
 
54
                return csclient.New(csclient.Params{
 
55
                        URL:          s.srv.URL,
 
56
                        BakeryClient: bakeryClient,
 
57
                })
56
58
        })
57
59
}
58
60
 
449
451
                c.Assert(err, jc.ErrorIsNil)
450
452
        }
451
453
}
 
454
 
 
455
func (s *UpgradeCharmCharmStoreSuite) TestUpgradeCharmWithChannel(c *gc.C) {
 
456
        id, ch := testcharms.UploadCharm(c, s.client, "cs:~client-username/trusty/wordpress-0", "wordpress")
 
457
        err := runDeploy(c, "cs:~client-username/trusty/wordpress-0")
 
458
        c.Assert(err, jc.ErrorIsNil)
 
459
 
 
460
        // Upload a new revision of the charm, but publish it
 
461
        // only to the development channel.
 
462
 
 
463
        id.Revision = 1
 
464
        err = s.client.UploadCharmWithRevision(id, ch, -1)
 
465
        c.Assert(err, gc.IsNil)
 
466
 
 
467
        err = s.client.Publish(id, []csclientparams.Channel{csclientparams.DevelopmentChannel}, nil)
 
468
        c.Assert(err, gc.IsNil)
 
469
 
 
470
        err = runUpgradeCharm(c, "wordpress", "--channel", "development")
 
471
        c.Assert(err, gc.IsNil)
 
472
 
 
473
        s.assertCharmsUploaded(c, "cs:~client-username/trusty/wordpress-0", "cs:~client-username/trusty/wordpress-1")
 
474
        s.assertServicesDeployed(c, map[string]serviceInfo{
 
475
                "wordpress": {charm: "cs:~client-username/trusty/wordpress-1"},
 
476
        })
 
477
}