Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(446)

Side by Side Diff: names/user_test.go

Issue 92560043: Validate usernames
Patch Set: Created 9 years, 10 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 Canonical Ltd. 1 // Copyright 2013 Canonical Ltd.
2 // Licensed under the AGPLv3, see LICENCE file for details. 2 // Licensed under the AGPLv3, see LICENCE file for details.
3 3
4 package names_test 4 package names_test
5 5
6 import ( 6 import (
7 jc "github.com/juju/testing/checkers" 7 jc "github.com/juju/testing/checkers"
8 gc "launchpad.net/gocheck" 8 gc "launchpad.net/gocheck"
9 9
10 "launchpad.net/juju-core/names" 10 "launchpad.net/juju-core/names"
11 ) 11 )
12 12
13 type userSuite struct{} 13 type userSuite struct{}
14 14
15 var _ = gc.Suite(&userSuite{}) 15 var _ = gc.Suite(&userSuite{})
16 16
17 func (s *userSuite) TestUserTag(c *gc.C) { 17 func (s *userSuite) TestUserTag(c *gc.C) {
18 c.Assert(names.UserTag("admin"), gc.Equals, "user-admin") 18 c.Assert(names.UserTag("admin"), gc.Equals, "user-admin")
19 } 19 }
20 20
21 // This is third place we are testing username validation. Amalgamate?
menn0 2014/05/21 23:06:15 As per earlier comment, move most of the testing h
21 func (s *userSuite) TestIsUser(c *gc.C) { 22 func (s *userSuite) TestIsUser(c *gc.C) {
22 c.Assert(names.IsUser("admin"), jc.IsTrue) 23 c.Assert(names.IsUser("admin"), jc.IsTrue)
23 c.Assert(names.IsUser("foo42"), jc.IsTrue) 24 c.Assert(names.IsUser("foo42"), jc.IsTrue)
24 c.Assert(names.IsUser("not/valid"), jc.IsFalse) 25 c.Assert(names.IsUser("not/valid"), jc.IsFalse)
25 c.Assert(names.IsUser(""), jc.IsFalse) 26 c.Assert(names.IsUser(""), jc.IsFalse)
26 } 27 }
OLDNEW

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b