2021-11-11 08:03:30 +01:00
|
|
|
// Copyright 2020 The Gitea Authors. All rights reserved.
|
2022-11-27 19:20:29 +01:00
|
|
|
// SPDX-License-Identifier: MIT
|
2021-11-11 08:03:30 +01:00
|
|
|
|
2022-06-15 09:02:00 +02:00
|
|
|
package user_test
|
2021-11-11 08:03:30 +01:00
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2023-09-25 15:17:37 +02:00
|
|
|
"code.gitea.io/gitea/models/db"
|
2021-11-12 15:36:47 +01:00
|
|
|
"code.gitea.io/gitea/models/unittest"
|
2022-06-15 09:02:00 +02:00
|
|
|
user_model "code.gitea.io/gitea/models/user"
|
2021-11-12 15:36:47 +01:00
|
|
|
|
2021-11-11 08:03:30 +01:00
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestLookupUserRedirect(t *testing.T) {
|
2021-11-12 15:36:47 +01:00
|
|
|
assert.NoError(t, unittest.PrepareTestDatabase())
|
2021-11-11 08:03:30 +01:00
|
|
|
|
2023-09-25 15:17:37 +02:00
|
|
|
userID, err := user_model.LookupUserRedirect(db.DefaultContext, "olduser1")
|
2021-11-11 08:03:30 +01:00
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.EqualValues(t, 1, userID)
|
|
|
|
|
2023-09-25 15:17:37 +02:00
|
|
|
_, err = user_model.LookupUserRedirect(db.DefaultContext, "doesnotexist")
|
2022-06-15 09:02:00 +02:00
|
|
|
assert.True(t, user_model.IsErrUserRedirectNotExist(err))
|
2021-11-11 08:03:30 +01:00
|
|
|
}
|