1
// Copyright 2016 Canonical Ltd.
2
// Licensed under the AGPLv3, see LICENCE file for info.
8
jc "github.com/juju/testing/checkers"
11
"github.com/juju/juju/cmd/juju/machine"
12
"github.com/juju/juju/testing"
15
type MachineShowCommandSuite struct {
16
testing.FakeJujuXDGDataHomeSuite
19
var _ = gc.Suite(&MachineShowCommandSuite{})
21
func newMachineShowCommand() cmd.Command {
22
return machine.NewShowCommandForTest(&fakeStatusAPI{})
25
func (s *MachineShowCommandSuite) SetUpTest(c *gc.C) {
26
s.FakeJujuXDGDataHomeSuite.SetUpTest(c)
29
func (s *MachineShowCommandSuite) TestShowMachine(c *gc.C) {
30
context, err := testing.RunCommand(c, newMachineShowCommand())
31
c.Assert(err, jc.ErrorIsNil)
32
c.Assert(testing.Stdout(context), gc.Equals, ""+
37
" current: started\n"+
38
" dns-name: 10.0.0.1\n"+
39
" instance-id: juju-badd06-0\n"+
41
" hardware: availability-zone=us-east-1\n"+
44
" current: started\n"+
45
" dns-name: 10.0.0.2\n"+
46
" instance-id: juju-badd06-1\n"+
51
" current: pending\n"+
52
" dns-name: 10.0.0.3\n"+
53
" instance-id: juju-badd06-1-lxd-0\n"+
56
func (s *MachineShowCommandSuite) TestShowSingleMachine(c *gc.C) {
57
context, err := testing.RunCommand(c, newMachineShowCommand(), "0")
58
c.Assert(err, jc.ErrorIsNil)
59
c.Assert(testing.Stdout(context), gc.Equals, ""+
64
" current: started\n"+
65
" dns-name: 10.0.0.1\n"+
66
" instance-id: juju-badd06-0\n"+
68
" hardware: availability-zone=us-east-1\n")
71
func (s *MachineShowCommandSuite) TestShowTabularMachine(c *gc.C) {
72
context, err := testing.RunCommand(c, newMachineShowCommand(), "--format", "tabular", "0", "1")
73
c.Assert(err, jc.ErrorIsNil)
74
c.Assert(testing.Stdout(context), gc.Equals, ""+
75
"MACHINE STATE DNS INS-ID SERIES AZ\n"+
76
"0 started 10.0.0.1 juju-badd06-0 trusty us-east-1\n"+
77
"1 started 10.0.0.2 juju-badd06-1 trusty \n"+
78
" 1/lxd/0 pending 10.0.0.3 juju-badd06-1-lxd-0 trusty \n"+
82
func (s *MachineShowCommandSuite) TestShowJsonMachine(c *gc.C) {
83
context, err := testing.RunCommand(c, newMachineShowCommand(), "--format", "json", "0", "1")
84
c.Assert(err, jc.ErrorIsNil)
85
c.Assert(testing.Stdout(context), gc.Equals, ""+
86
"{\"model\":\"dummyenv\",\"machines\":{\"0\":{\"juju-status\":{\"current\":\"started\"},\"dns-name\":\"10.0.0.1\",\"instance-id\":\"juju-badd06-0\",\"machine-status\":{},\"series\":\"trusty\",\"hardware\":\"availability-zone=us-east-1\"},\"1\":{\"juju-status\":{\"current\":\"started\"},\"dns-name\":\"10.0.0.2\",\"instance-id\":\"juju-badd06-1\",\"machine-status\":{},\"series\":\"trusty\",\"containers\":{\"1/lxd/0\":{\"juju-status\":{\"current\":\"pending\"},\"dns-name\":\"10.0.0.3\",\"instance-id\":\"juju-badd06-1-lxd-0\",\"machine-status\":{},\"series\":\"trusty\"}}}}}\n")