func (s *ShowCommandSuite) TestShow(c *gc.C) { _, err := testing.RunCommand(c, model.NewShowCommandForTest(&s.fake, s.store)) c.Assert(err, jc.ErrorIsNil) s.fake.CheckCalls(c, []gitjujutesting.StubCall{ {"ModelInfo", []interface{}{[]names.ModelTag{testing.ModelTag}}}, {"Close", nil}, }) }
func (s *ShowCommandSuite) TestShowUnknownCallsRefresh(c *gc.C) { called := false refresh := func(jujuclient.ClientStore, string) error { called = true return nil } _, err := testing.RunCommand(c, model.NewShowCommandForTest(&s.fake, refresh, s.store), "unknown") c.Check(called, jc.IsTrue) c.Check(err, jc.Satisfies, errors.IsNotFound) }
func (s *ShowCommandSuite) TestShowFormatJson(c *gc.C) { ctx, err := testing.RunCommand(c, model.NewShowCommandForTest(&s.fake, s.store), "--format", "json") c.Assert(err, jc.ErrorIsNil) c.Assert(testing.Stdout(ctx), gc.Equals, ""+ `{"mymodel":{"model-uuid":"deadbeef-0bad-400d-8000-4b1d0d06f00d",`+ `"controller-uuid":"1ca2293b-fdb9-4299-97d6-55583bb39364",`+ `"owner":"admin@local","type":"openstack",`+ `"users":{"admin@local":{"access":"write","last-connection":"2015-03-20"},`+ `"bob@local":{"display-name":"Bob","access":"read","last-connection":"never connected"}}}} `) }
func (s *ShowCommandSuite) TestShowFormatYaml(c *gc.C) { ctx, err := testing.RunCommand(c, model.NewShowCommandForTest(&s.fake, s.store), "--format", "yaml") c.Assert(err, jc.ErrorIsNil) c.Assert(testing.Stdout(ctx), gc.Equals, ` mymodel: model-uuid: deadbeef-0bad-400d-8000-4b1d0d06f00d controller-uuid: 1ca2293b-fdb9-4299-97d6-55583bb39364 owner: admin@local type: openstack users: admin@local: access: write last-connection: 2015-03-20 bob@local: display-name: Bob access: read last-connection: never connected `[1:]) }
func (s *ShowCommandSuite) TestUnrecognizedArg(c *gc.C) { _, err := testing.RunCommand(c, model.NewShowCommandForTest(&s.fake, s.store), "admin", "whoops") c.Assert(err, gc.ErrorMatches, `unrecognized args: \["whoops"\]`) }
func (s *ShowCommandSuite) TestShowFormatJson(c *gc.C) { ctx, err := testing.RunCommand(c, model.NewShowCommandForTest(&s.fake, s.store), "--format", "json") c.Assert(err, jc.ErrorIsNil) c.Assert(testing.Stdout(ctx), jc.JSONEquals, s.expectedOutput) }
func (s *ShowCommandSuite) newShowCommand() cmd.Command { return model.NewShowCommandForTest(&s.fake, noOpRefresh, s.store) }