github.com/mattyw/juju@v0.0.0-20140610034352-732aecd63861/cmd/juju/endpoint_test.go (about) 1 // Copyright 2012, 2013 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 package main 5 6 import ( 7 "bytes" 8 "fmt" 9 10 gc "launchpad.net/gocheck" 11 12 "github.com/juju/juju/cmd" 13 "github.com/juju/juju/cmd/envcmd" 14 "github.com/juju/juju/juju/testing" 15 coretesting "github.com/juju/juju/testing" 16 ) 17 18 type EndpointSuite struct { 19 testing.JujuConnSuite 20 } 21 22 var _ = gc.Suite(&EndpointSuite{}) 23 24 func (s *EndpointSuite) TestEndpoint(c *gc.C) { 25 ctx := coretesting.Context(c) 26 code := cmd.Main(envcmd.Wrap(&EndpointCommand{}), ctx, []string{}) 27 c.Check(code, gc.Equals, 0) 28 c.Assert(ctx.Stderr.(*bytes.Buffer).String(), gc.Equals, "") 29 output := string(ctx.Stdout.(*bytes.Buffer).Bytes()) 30 info := s.APIInfo(c) 31 c.Assert(output, gc.Equals, fmt.Sprintf("%s\n", info.Addrs[0])) 32 }