Esempio n. 1
0
func (s *listCommandSuite) TestListJSON(c *gc.C) {
	cmd := block.NewListCommandForTest(s.mock(), nil)
	ctx, err := testing.RunCommand(c, cmd, "--format", "json")
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(testing.Stdout(ctx), gc.Equals, ""+
		`[{"command-set":"destroy-model","message":"Sysadmins in control."},`+
		`{"command-set":"all","message":"just temporary"}]`+"\n")
}
Esempio n. 2
0
func (s *listCommandSuite) TestListAllJSON(c *gc.C) {
	cmd := block.NewListCommandForTest(s.mock(), nil)
	ctx, err := testing.RunCommand(c, cmd, "--format", "json", "--all")
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(testing.Stdout(ctx), gc.Equals, "["+
		`{"name":"controller","model-uuid":"fake-uuid-1","owner":"admin","disabled-commands":["destroy-model","remove-object"]},`+
		`{"name":"model-a","model-uuid":"fake-uuid-2","owner":"bob@external","disabled-commands":["all"]},`+
		`{"name":"model-b","model-uuid":"fake-uuid-3","owner":"charlie@external","disabled-commands":["all","destroy-model"]}`+
		"]\n")
}
Esempio n. 3
0
func (s *listCommandSuite) TestListYAML(c *gc.C) {
	cmd := block.NewListCommandForTest(s.mock(), nil)
	ctx, err := testing.RunCommand(c, cmd, "--format", "yaml")
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(testing.Stdout(ctx), gc.Equals, ""+
		"- command-set: destroy-model\n"+
		"  message: Sysadmins in control.\n"+
		"- command-set: all\n"+
		"  message: just temporary\n",
	)
}
Esempio n. 4
0
func (s *listCommandSuite) TestList(c *gc.C) {
	cmd := block.NewListCommandForTest(s.mock(), nil)
	ctx, err := testing.RunCommand(c, cmd)
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(testing.Stderr(ctx), gc.Equals, "")
	c.Assert(testing.Stdout(ctx), gc.Equals, ""+
		"Disabled commands  Message\n"+
		"destroy-model      Sysadmins in control.\n"+
		"all                just temporary\n"+
		"\n",
	)
}
Esempio n. 5
0
func (s *listCommandSuite) TestListAll(c *gc.C) {
	cmd := block.NewListCommandForTest(s.mock(), nil)
	ctx, err := testing.RunCommand(c, cmd, "--all")
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(testing.Stderr(ctx), gc.Equals, "")
	c.Assert(testing.Stdout(ctx), gc.Equals, ""+
		"Name        Model UUID   Owner             Disabled commands\n"+
		"controller  fake-uuid-1  admin             destroy-model, remove-object\n"+
		"model-a     fake-uuid-2  bob@external      all\n"+
		"model-b     fake-uuid-3  charlie@external  all, destroy-model\n"+
		"\n")
}
Esempio n. 6
0
func (s *listCommandSuite) TestListAll(c *gc.C) {
	cmd := block.NewListCommandForTest(s.mock(), nil)
	ctx, err := testing.RunCommand(c, cmd, "--all")
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(testing.Stderr(ctx), gc.Equals, "")
	c.Assert(testing.Stdout(ctx), gc.Equals, ""+
		"NAME        MODEL UUID   OWNER             DISABLED COMMANDS\n"+
		"controller  fake-uuid-1  admin@local       destroy-model, remove-object\n"+
		"model-a     fake-uuid-2  bob@external      all\n"+
		"model-b     fake-uuid-3  charlie@external  all, destroy-model\n"+
		"\n")
}
Esempio n. 7
0
func (s *listCommandSuite) TestListAllYAML(c *gc.C) {
	cmd := block.NewListCommandForTest(s.mock(), nil)
	ctx, err := testing.RunCommand(c, cmd, "--format", "yaml", "--all")
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(testing.Stdout(ctx), gc.Equals, ""+
		"- name: controller\n"+
		"  model-uuid: fake-uuid-1\n"+
		"  owner: admin\n"+
		"  disabled-commands:\n"+
		"  - destroy-model\n"+
		"  - remove-object\n"+
		"- name: model-a\n"+
		"  model-uuid: fake-uuid-2\n"+
		"  owner: bob@external\n"+
		"  disabled-commands:\n"+
		"  - all\n"+
		"- name: model-b\n"+
		"  model-uuid: fake-uuid-3\n"+
		"  owner: charlie@external\n"+
		"  disabled-commands:\n"+
		"  - all\n"+
		"  - destroy-model\n")
}
Esempio n. 8
0
func (s *listCommandSuite) TestListError(c *gc.C) {
	_, err := testing.RunCommand(c, block.NewListCommandForTest(
		&mockListClient{err: errors.New("boom")}, nil))
	c.Assert(err, gc.ErrorMatches, "boom")
}
Esempio n. 9
0
func (s *listCommandSuite) TestListEmpty(c *gc.C) {
	ctx, err := testing.RunCommand(c, block.NewListCommandForTest(&mockListClient{}, nil))
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(testing.Stderr(ctx), gc.Equals, "No commands are currently disabled.\n")
}
Esempio n. 10
0
func (s *listCommandSuite) TestListJSONEmpty(c *gc.C) {
	ctx, err := testing.RunCommand(c, block.NewListCommandForTest(&mockListClient{}, nil), "--format", "json")
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(testing.Stdout(ctx), gc.Equals, "[]\n")
}