github.com/mhilton/juju-juju@v0.0.0-20150901100907-a94dd2c73455/featuretests/charms_test.go (about) 1 // Copyright 2015 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 package featuretests 5 6 import ( 7 jc "github.com/juju/testing/checkers" 8 gc "gopkg.in/check.v1" 9 10 "github.com/juju/juju/api/charms" 11 jujutesting "github.com/juju/juju/juju/testing" 12 "github.com/juju/juju/testing/factory" 13 ) 14 15 type apiCharmsSuite struct { 16 jujutesting.JujuConnSuite 17 charmsClient *charms.Client 18 } 19 20 func (s *apiCharmsSuite) SetUpTest(c *gc.C) { 21 s.JujuConnSuite.SetUpTest(c) 22 s.charmsClient = charms.NewClient(s.APIState) 23 c.Assert(s.charmsClient, gc.NotNil) 24 } 25 26 func (s *apiCharmsSuite) TearDownTest(c *gc.C) { 27 s.charmsClient.ClientFacade.Close() 28 s.JujuConnSuite.TearDownTest(c) 29 } 30 31 func (s *apiCharmsSuite) TestCharmsListFacadeCall(c *gc.C) { 32 s.Factory.MakeCharm(c, &factory.CharmParams{ 33 Name: "wordpress", 34 URL: "cs:quantal/wordpress-1", 35 }) 36 37 found, err := s.charmsClient.List([]string{"wordpress"}) 38 c.Assert(err, jc.ErrorIsNil) 39 c.Assert(found, gc.HasLen, 1) 40 c.Assert(found[0], gc.DeepEquals, "cs:quantal/wordpress-1") 41 } 42 43 func (s *apiCharmsSuite) TestCharmInfoFacadeCall(c *gc.C) { 44 s.Factory.MakeCharm(c, &factory.CharmParams{ 45 Name: "wordpress", 46 URL: "cs:quantal/wordpress-1", 47 }) 48 49 found, err := s.charmsClient.CharmInfo("cs:quantal/wordpress-1") 50 c.Assert(err, jc.ErrorIsNil) 51 c.Assert(found.URL, gc.DeepEquals, "cs:quantal/wordpress-1") 52 }