Address review comments: use actorDisplayName for Copilot author display
- Add actorDisplayName call in CommentAuthor.DisplayName for consistency - Use require.Equal in TestActorDisplayName instead of manual comparisons - Simplify user type name constant usage Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
parent
3651c289ed
commit
e047fa6b0e
3 changed files with 4 additions and 6 deletions
|
|
@ -143,6 +143,7 @@ type RequestedReviewer struct {
|
|||
|
||||
const teamTypeName = "Team"
|
||||
const botTypeName = "Bot"
|
||||
const userTypeName = "User"
|
||||
|
||||
func (r RequestedReviewer) LoginOrSlug() string {
|
||||
if r.TypeName == teamTypeName {
|
||||
|
|
|
|||
|
|
@ -1135,7 +1135,7 @@ func NewAssignableUser(id, login, name string) AssignableUser {
|
|||
|
||||
// DisplayName returns a user-friendly name via actorDisplayName.
|
||||
func (u AssignableUser) DisplayName() string {
|
||||
return actorDisplayName("User", u.login, u.name)
|
||||
return actorDisplayName(userTypeName, u.login, u.name)
|
||||
}
|
||||
|
||||
func (u AssignableUser) ID() string {
|
||||
|
|
@ -1165,7 +1165,7 @@ func NewAssignableBot(id, login string) AssignableBot {
|
|||
}
|
||||
|
||||
func (b AssignableBot) DisplayName() string {
|
||||
return actorDisplayName("Bot", b.login, "")
|
||||
return actorDisplayName(botTypeName, b.login, "")
|
||||
}
|
||||
|
||||
func (b AssignableBot) ID() string {
|
||||
|
|
|
|||
|
|
@ -583,10 +583,7 @@ func TestActorDisplayName(t *testing.T) {
|
|||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
got := actorDisplayName(tt.typeName, tt.login, tt.actName)
|
||||
if got != tt.want {
|
||||
t.Errorf("actorDisplayName(%q, %q, %q) = %q, want %q", tt.typeName, tt.login, tt.actName, got, tt.want)
|
||||
}
|
||||
require.Equal(t, tt.want, actorDisplayName(tt.typeName, tt.login, tt.actName))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue