Exemplo n.º 1
0
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},
	})
}
Exemplo n.º 2
0
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)
}
Exemplo n.º 3
0
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"}}}}
`)
}
Exemplo n.º 4
0
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:])
}
Exemplo n.º 5
0
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"\]`)
}
Exemplo n.º 6
0
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)
}
Exemplo n.º 7
0
func (s *ShowCommandSuite) newShowCommand() cmd.Command {
	return model.NewShowCommandForTest(&s.fake, noOpRefresh, s.store)
}