2021-11-11 07:03:30 +00: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.
|
|
|
|
|
|
|
|
package user
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2021-11-12 14:36:47 +00:00
|
|
|
"code.gitea.io/gitea/models/unittest"
|
|
|
|
|
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
|
|
|
|
|
|
|
userID, err := LookupUserRedirect("olduser1")
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.EqualValues(t, 1, userID)
|
|
|
|
|
|
|
|
_, err = LookupUserRedirect("doesnotexist")
|
|
|
|
assert.True(t, IsErrUserRedirectNotExist(err))
|
|
|
|
}
|