github.com/niedbalski/juju@v0.0.0-20190215020005-8ff100488e47/featuretests/cmd_juju_deploy_test.go (about) 1 // Copyright 2018 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 package featuretests 5 6 import ( 7 "github.com/juju/cmd/cmdtesting" 8 "github.com/juju/errors" 9 jc "github.com/juju/testing/checkers" 10 gc "gopkg.in/check.v1" 11 "gopkg.in/juju/charm.v6" 12 13 "github.com/juju/juju/juju/testing" 14 "github.com/juju/juju/testcharms" 15 ) 16 17 type cmdDeploySuite struct { 18 testing.JujuConnSuite 19 } 20 21 func (s *cmdDeploySuite) TestLocalDeploySuccess(c *gc.C) { 22 ch := testcharms.Repo.CharmDir("storage-filesystem-subordinate") // has hooks 23 ctx, err := runCommand(c, "deploy", ch.Path, "--series", "quantal") 24 c.Assert(err, jc.ErrorIsNil) 25 c.Assert(cmdtesting.Stderr(ctx), jc.Contains, `Deploying charm "local:quantal/storage-filesystem-subordinate-1"`) 26 c.Assert(cmdtesting.Stdout(ctx), gc.Equals, "") 27 savedCh, err := s.State.Charm(charm.MustParseURL("local:quantal/storage-filesystem-subordinate-1")) 28 c.Assert(err, jc.ErrorIsNil) 29 c.Assert(savedCh, gc.NotNil) 30 } 31 32 func (s *cmdDeploySuite) TestLocalDeployFailNoHook(c *gc.C) { 33 ch := testcharms.Repo.CharmDir("category") // has no hooks 34 ctx, err := runCommand(c, "deploy", ch.Path, "--series", "quantal") 35 c.Assert(err, gc.NotNil) 36 c.Assert(cmdtesting.Stderr(ctx), jc.Contains, `invalid charm "category": has no hooks`) 37 c.Assert(cmdtesting.Stdout(ctx), gc.Equals, "") 38 _, err = s.State.Charm(charm.MustParseURL("local:quantal/category")) 39 c.Assert(err, jc.Satisfies, errors.IsNotFound) 40 } 41 42 // The following LXDProfile feature tests are to ensure that we can deploy a 43 // charm (subordinate charm) and that it passes the validation stages of 44 // deployment. These tests don't validate that the charm was successfully stood 45 // up once deployed. 46 47 func (s *cmdDeploySuite) TestLocalDeployLXDProfileSuccess(c *gc.C) { 48 ch := testcharms.Repo.CharmDir("lxd-profile-subordinate") // has hooks 49 ctx, err := runCommand(c, "deploy", ch.Path, "--series", "quantal") 50 c.Assert(err, jc.ErrorIsNil) 51 c.Assert(cmdtesting.Stderr(ctx), jc.Contains, `Deploying charm "local:quantal/lxd-profile-subordinate-0"`) 52 c.Assert(cmdtesting.Stdout(ctx), gc.Equals, "") 53 savedCh, err := s.State.Charm(charm.MustParseURL("local:quantal/lxd-profile-subordinate-0")) 54 c.Assert(err, jc.ErrorIsNil) 55 c.Assert(savedCh, gc.NotNil) 56 } 57 58 func (s *cmdDeploySuite) TestLocalDeployLXDProfileWithBadConfigSuccess(c *gc.C) { 59 ch := testcharms.Repo.CharmDir("lxd-profile-subordinate-fail") // has hooks 60 ctx, err := runCommand(c, "deploy", ch.Path, "--series", "quantal") 61 c.Assert(err, gc.ErrorMatches, "cmd: error out silently") 62 c.Assert(cmdtesting.Stderr(ctx), jc.Contains, `ERROR invalid lxd-profile.yaml: contains device type "unix-disk"`) 63 c.Assert(cmdtesting.Stdout(ctx), gc.Equals, "") 64 }