All checks were successful
DevStar Studio CI/CD Pipeline / DevStarStudio-CICD-Pipeline (push) Successful in 53m22s
<!-- start tips --> Please check the following: 1. Make sure you are targeting the `main` branch, pull requests on release branches are only allowed for backports. 2. Make sure you have read contributing guidelines: https://github.com/go-gitea/gitea/blob/main/CONTRIBUTING.md . 3. For documentations contribution, please go to https://gitea.com/gitea/docs 4. Describe what your pull request does and which issue you're targeting (if any). 5. It is recommended to enable "Allow edits by maintainers", so maintainers can help more easily. 6. Your input here will be included in the commit message when this PR has been merged. If you don't want some content to be included, please separate them with a line like `---`. 7. Delete all these tips before posting. <!-- end tips --> Co-authored-by: 孟宁 <mengning997@163.com> Co-authored-by: panshuxiao <panshuxiao@mail.ustc.edu.cn> Co-authored-by: jiaojm <13763605353@163.com> Co-authored-by: 24焦俊鸣 <13763605353@163.com> Reviewed-on: #21 Co-authored-by: mengning <mengning@mengning.com.cn> Co-committed-by: mengning <mengning@mengning.com.cn>
33 lines
845 B
Go
33 lines
845 B
Go
// Copyright 2025 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package user
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"code.gitea.io/gitea/models/db"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestSystemUser(t *testing.T) {
|
|
u, err := GetPossibleUserByID(db.DefaultContext, -1)
|
|
require.NoError(t, err)
|
|
assert.Equal(t, "Ghost", u.Name)
|
|
assert.Equal(t, "ghost", u.LowerName)
|
|
assert.True(t, u.IsGhost())
|
|
assert.True(t, IsGhostUserName("gHost"))
|
|
|
|
u, err = GetPossibleUserByID(db.DefaultContext, -2)
|
|
require.NoError(t, err)
|
|
assert.Equal(t, "devstar-actions", u.Name)
|
|
assert.Equal(t, "devstar-actions", u.LowerName)
|
|
assert.True(t, u.IsGiteaActions())
|
|
assert.True(t, IsGiteaActionsUserName("Devstar-actionS"))
|
|
|
|
_, err = GetPossibleUserByID(db.DefaultContext, -3)
|
|
require.Error(t, err)
|
|
}
|