summaryrefslogtreecommitdiffstats
path: root/model/team_test.go
diff options
context:
space:
mode:
authorJoramWilander <jwawilander@gmail.com>2015-08-28 08:37:55 -0400
committerJoramWilander <jwawilander@gmail.com>2015-08-28 08:37:55 -0400
commitf5fec3a157e6c9146a0c4e28dd5f70e6c066affd (patch)
tree176afd630a3afbe0ac3389695be6b4ce1c45d069 /model/team_test.go
parentdb7e8c12889485234fb2d1ba6556106e5fc7548b (diff)
downloadchat-f5fec3a157e6c9146a0c4e28dd5f70e6c066affd.tar.gz
chat-f5fec3a157e6c9146a0c4e28dd5f70e6c066affd.tar.bz2
chat-f5fec3a157e6c9146a0c4e28dd5f70e6c066affd.zip
Added the ability to create a team with SSO services and added the ability to turn off email sign up.
Diffstat (limited to 'model/team_test.go')
-rw-r--r--model/team_test.go59
1 files changed, 59 insertions, 0 deletions
diff --git a/model/team_test.go b/model/team_test.go
index 071b1a2e9..0dec07559 100644
--- a/model/team_test.go
+++ b/model/team_test.go
@@ -74,3 +74,62 @@ func TestTeamPreUpdate(t *testing.T) {
o := Team{DisplayName: "test"}
o.PreUpdate()
}
+
+var domains = []struct {
+ value string
+ expected bool
+}{
+ {"spin-punch", true},
+ {"-spin-punch", false},
+ {"spin-punch-", false},
+ {"spin_punch", false},
+ {"a", false},
+ {"aa", false},
+ {"aaa", false},
+ {"aaa-999b", true},
+ {"b00b", true},
+ {"b))b", false},
+ {"test", true},
+}
+
+func TestValidTeamName(t *testing.T) {
+ for _, v := range domains {
+ if IsValidTeamName(v.value) != v.expected {
+ t.Errorf("expect %v as %v", v.value, v.expected)
+ }
+ }
+}
+
+var tReservedDomains = []struct {
+ value string
+ expected bool
+}{
+ {"test-hello", true},
+ {"test", true},
+ {"admin", true},
+ {"Admin-punch", true},
+ {"spin-punch-admin", false},
+}
+
+func TestReservedTeamName(t *testing.T) {
+ for _, v := range tReservedDomains {
+ if IsReservedTeamName(v.value) != v.expected {
+ t.Errorf("expect %v as %v", v.value, v.expected)
+ }
+ }
+}
+
+func TestCleanTeamName(t *testing.T) {
+ if CleanTeamName("Jimbo's Team") != "jimbos-team" {
+ t.Fatal("didn't clean name properly")
+ }
+ if len(CleanTeamName("Test")) != 26 {
+ t.Fatal("didn't clean name properly")
+ }
+ if CleanTeamName("Team Really cool") != "really-cool" {
+ t.Fatal("didn't clean name properly")
+ }
+ if CleanTeamName("super-duper-guys") != "super-duper-guys" {
+ t.Fatal("didn't clean name properly")
+ }
+}