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