示例#1
0
func (s *UsersCommandSuite) TestModelUsersFormatJson(c *gc.C) {
	context, err := testing.RunCommand(c, model.NewUsersCommandForTest(s.fake), "-m", "dummymodel", "--format", "json")
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(testing.Stdout(context), gc.Equals, "["+
		`{"user-name":"admin@local","date-created":"2014-07-20","last-connection":"2015-03-20"},`+
		`{"user-name":"bob@local","date-created":"2015-02-15","last-connection":"2015-03-01"},`+
		`{"user-name":"*****@*****.**","date-created":"2015-02-15","last-connection":"never connected"}`+
		"]\n")
}
示例#2
0
func (s *UsersCommandSuite) TestModelUsersFormatJson(c *gc.C) {
	context, err := testing.RunCommand(c, model.NewUsersCommandForTest(s.fake, s.store), "-m", "admin", "--format", "json")
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(testing.Stdout(context), gc.Equals, "{"+
		`"admin@local":{"access":"write","last-connection":"2015-03-20"},`+
		`"bob@local":{"display-name":"Bob","access":"read","last-connection":"2015-03-01"},`+
		`"*****@*****.**":{"display-name":"Charlie","access":"read","last-connection":"never connected"}`+
		"}\n")
}
示例#3
0
func (s *UsersCommandSuite) TestModelUsers(c *gc.C) {
	context, err := testing.RunCommand(c, model.NewUsersCommandForTest(s.fake), "-m", "dummymodel")
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(testing.Stdout(context), gc.Equals, ""+
		"NAME                DATE CREATED  LAST CONNECTION\n"+
		"admin@local         2014-07-20    2015-03-20\n"+
		"bob@local           2015-02-15    2015-03-01\n"+
		"[email protected]  2015-02-15    never connected\n"+
		"\n")
}
示例#4
0
func (s *UsersCommandSuite) TestModelUsers(c *gc.C) {
	context, err := testing.RunCommand(c, model.NewUsersCommandForTest(s.fake, s.store), "-m", "admin")
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(testing.Stdout(context), gc.Equals, ""+
		"NAME                          ACCESS  LAST CONNECTION\n"+
		"admin@local                   write   2015-03-20\n"+
		"bob@local (Bob)               read    2015-03-01\n"+
		"[email protected] (Charlie)  read    never connected\n"+
		"\n")
}
示例#5
0
func (s *UsersCommandSuite) TestUserInfoFormatYaml(c *gc.C) {
	context, err := testing.RunCommand(c, model.NewUsersCommandForTest(s.fake), "-m", "dummymodel", "--format", "yaml")
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(testing.Stdout(context), gc.Equals, ""+
		"- user-name: admin@local\n"+
		"  date-created: 2014-07-20\n"+
		"  last-connection: 2015-03-20\n"+
		"- user-name: bob@local\n"+
		"  date-created: 2015-02-15\n"+
		"  last-connection: 2015-03-01\n"+
		"- user-name: [email protected]\n"+
		"  date-created: 2015-02-15\n"+
		"  last-connection: never connected\n")
}
示例#6
0
func (s *UsersCommandSuite) TestUserInfoFormatYaml(c *gc.C) {
	context, err := testing.RunCommand(c, model.NewUsersCommandForTest(s.fake, s.store), "-m", "admin", "--format", "yaml")
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(testing.Stdout(context), gc.Equals, ""+
		"admin@local:\n"+
		"  access: write\n"+
		"  last-connection: 2015-03-20\n"+
		"bob@local:\n"+
		"  display-name: Bob\n"+
		"  access: read\n"+
		"  last-connection: 2015-03-01\n"+
		"[email protected]:\n"+
		"  display-name: Charlie\n"+
		"  access: read\n"+
		"  last-connection: never connected\n")
}
示例#7
0
func (s *UsersCommandSuite) TestUnrecognizedArg(c *gc.C) {
	_, err := testing.RunCommand(c, model.NewUsersCommandForTest(s.fake), "-m", "dummymodel", "whoops")
	c.Assert(err, gc.ErrorMatches, `unrecognized args: \["whoops"\]`)
}