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