2021-11-11 02:03:30 -05:00
|
|
|
// Copyright 2020 The Gitea Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a MIT-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
2022-06-15 03:02:00 -04:00
|
|
|
package user_test
|
2021-11-11 02:03:30 -05:00
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
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
|
|
|
|
2022-06-15 03:02:00 -04:00
|
|
|
userID, err := user_model.LookupUserRedirect("olduser1")
|
2021-11-11 02:03:30 -05:00
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.EqualValues(t, 1, userID)
|
|
|
|
|
2022-06-15 03:02:00 -04:00
|
|
|
_, err = user_model.LookupUserRedirect("doesnotexist")
|
|
|
|
assert.True(t, user_model.IsErrUserRedirectNotExist(err))
|
2021-11-11 02:03:30 -05:00
|
|
|
}
|