From b7918a694eb99aeb03b783706d100023e55923de Mon Sep 17 00:00:00 2001 From: kolaente Date: Sat, 25 May 2019 10:29:14 +0200 Subject: [PATCH] Added test for uid when creating a new team --- pkg/migration/20190525101422.go | 2 +- pkg/models/teams.go | 2 +- pkg/models/teams_test.go | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/pkg/migration/20190525101422.go b/pkg/migration/20190525101422.go index 45710da1eb..f0a118b26f 100644 --- a/pkg/migration/20190525101422.go +++ b/pkg/migration/20190525101422.go @@ -24,7 +24,7 @@ import ( type team20190525101422 struct { ID int64 `xorm:"int(11) autoincr not null unique pk"` - UID string `xorm:"varchar(32) not null default ''"` + UID string `xorm:"varchar(32) null"` Name string `xorm:"varchar(250) not null"` Description string `xorm:"varchar(250)"` CreatedByID int64 `xorm:"int(11) not null INDEX"` diff --git a/pkg/models/teams.go b/pkg/models/teams.go index d505a36671..3aad5bc046 100644 --- a/pkg/models/teams.go +++ b/pkg/models/teams.go @@ -23,7 +23,7 @@ type Team struct { // The unique, numeric id of this team. ID int64 `xorm:"int(11) autoincr not null unique pk" json:"id" param:"team"` // The unique uuid for this team. Used to give a team access to things. - UID string `xorm:"varchar(32) not null" json:"uid"` + UID string `xorm:"varchar(32) null" json:"uid"` // The name of this team. Name string `xorm:"varchar(250) not null" json:"name" valid:"required,runelength(5|250)" minLength:"5" maxLength:"250"` // The team's description. diff --git a/pkg/models/teams_test.go b/pkg/models/teams_test.go index c02096d17b..e857914f32 100644 --- a/pkg/models/teams_test.go +++ b/pkg/models/teams_test.go @@ -38,6 +38,8 @@ func TestTeam_Create(t *testing.T) { assert.True(t, allowed) err = dummyteam.Create(&doer) assert.NoError(t, err) + // Check the uid was created successfully + assert.NotEqual(t, "", dummyteam.UID) // Check if it was inserted and we're admin tm := Team{ID: dummyteam.ID}