feat: Users API, ownership transfer and removal of the legacy role string
This commit is contained in:
1 parent
094df63a7f
commit
80f7037d3a
124 files changed
+4644
-824
No files matched your search
@@ -119,16 +119,21 @@ func TestRoleRepositoryFailures(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
func TestBackfillUserRoleIDsWithoutBuiltInRoles(t *testing.T) {
|
||||
func TestBackfillWithoutBuiltInRoles(t *testing.T) {
|
||||
db := openUnmigratedSQLite(t)
|
||||
if err := db.AutoMigrate(&models.Role{}, &models.RolePermission{}, &models.User{}); err != nil {
|
||||
if err := db.AutoMigrate(&models.Role{}, &models.RolePermission{}, &models.User{}, &models.Invite{}, &models.MigrationMarker{}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
createUserRow(t, db, 1, "owner", nil)
|
||||
if err := database.BackfillUserRoleIDs(db); err != nil {
|
||||
t.Fatal(err)
|
||||
addLegacyRoleColumn(t, db)
|
||||
createUserRow(t, db, 1, nil)
|
||||
setLegacyRole(t, db, 1, "owner")
|
||||
if err := database.BackfillLegacyUserRoles(db); !errors.Is(err, role.ErrRoleNotFound) {
|
||||
t.Errorf("expected ErrRoleNotFound, got %v", err)
|
||||
}
|
||||
if userRow(t, db, 1).RoleID != nil {
|
||||
t.Errorf("role_id must stay unset when no built-in role exists")
|
||||
}
|
||||
if err := database.BackfillCreatedBy(db); err != nil {
|
||||
t.Errorf("created_by backfill without roles must do nothing, got %v", err)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user