@@ -23,6 +23,7 @@ import (
2323 "time"
2424
2525 "github.com/microsoft/azure-devops-go-api/azuredevops/v7"
26+ "github.com/microsoft/azure-devops-go-api/azuredevops/v7/webapi"
2627 "github.com/microsoft/azure-devops-go-api/azuredevops/v7/workitemtracking"
2728
2829 "github.com/ossf/scorecard/v5/clients"
@@ -31,10 +32,10 @@ import (
3132func TestWorkItemsHandler_listIssues (t * testing.T ) {
3233 t .Parallel ()
3334 tests := []struct {
34- mockSetup func (* workItemsHandler )
35- want []clients.Issue
36- wantErrStr string
3735 name string
36+ wantErrStr string
37+ mockSetup func (* workItemsHandler )
38+ want []clients.Issue
3839 }{
3940 {
4041 name : "happy path" ,
@@ -51,9 +52,14 @@ func TestWorkItemsHandler_listIssues(t *testing.T) {
5152 createdDate := "2024-01-01T00:00:00Z"
5253 workItemDetails := & []workitemtracking.WorkItem {
5354 {
54- Id : toPtr (1 ),
55- Url : toPtr ("http://example.com" ),
56- Fields : & map [string ]interface {}{"System.CreatedDate" : createdDate },
55+ Id : toPtr (1 ),
56+ Url : toPtr ("http://example.com" ),
57+ Fields : & map [string ]interface {}{
58+ "System.CreatedDate" : createdDate ,
59+ "System.CreatedBy" : map [string ]interface {}{
60+ "uniqueName" : "test-user" ,
61+ },
62+ },
5763 },
5864 }
5965 w .getWorkItems = func (ctx context.Context , args workitemtracking.GetWorkItemsArgs ) (* []workitemtracking.WorkItem , error ) {
@@ -63,7 +69,7 @@ func TestWorkItemsHandler_listIssues(t *testing.T) {
6369 commentTime := time .Date (2024 , 1 , 2 , 0 , 0 , 0 , 0 , time .UTC )
6470 comments := & workitemtracking.CommentList {
6571 Comments : & []workitemtracking.Comment {
66- {CreatedDate : & azuredevops.Time {Time : commentTime }},
72+ {CreatedDate : & azuredevops.Time {Time : commentTime }, CreatedBy : & webapi. IdentityRef { UniqueName : toPtr ( "test-user" )} },
6773 },
6874 }
6975 w .getWorkItemComments = func (ctx context.Context , args workitemtracking.GetCommentsArgs ) (* workitemtracking.CommentList , error ) {
@@ -72,10 +78,16 @@ func TestWorkItemsHandler_listIssues(t *testing.T) {
7278 },
7379 want : []clients.Issue {
7480 {
75- URI : toPtr ("http://example.com" ),
76- CreatedAt : toPtr (time .Date (2024 , 1 , 1 , 0 , 0 , 0 , 0 , time .UTC )),
81+ URI : toPtr ("http://example.com" ),
82+ CreatedAt : toPtr (time .Date (2024 , 1 , 1 , 0 , 0 , 0 , 0 , time .UTC )),
83+ Author : & clients.User {Login : "test-user" },
84+ AuthorAssociation : toPtr (clients .RepoAssociationMember ),
7785 Comments : []clients.IssueComment {
78- {CreatedAt : toPtr (time .Date (2024 , 1 , 2 , 0 , 0 , 0 , 0 , time .UTC ))},
86+ {
87+ CreatedAt : toPtr (time .Date (2024 , 1 , 2 , 0 , 0 , 0 , 0 , time .UTC )),
88+ Author : & clients.User {Login : "test-user" },
89+ AuthorAssociation : toPtr (clients .RepoAssociationMember ),
90+ },
7991 },
8092 },
8193 },
@@ -120,9 +132,14 @@ func TestWorkItemsHandler_listIssues(t *testing.T) {
120132 createdDate := "2024-01-01T00:00:00Z"
121133 workItemDetails := & []workitemtracking.WorkItem {
122134 {
123- Id : toPtr (1 ),
124- Url : toPtr ("http://example.com" ),
125- Fields : & map [string ]interface {}{"System.CreatedDate" : createdDate },
135+ Id : toPtr (1 ),
136+ Url : toPtr ("http://example.com" ),
137+ Fields : & map [string ]interface {}{
138+ "System.CreatedDate" : createdDate ,
139+ "System.CreatedBy" : map [string ]interface {}{
140+ "uniqueName" : "test-user" ,
141+ },
142+ },
126143 },
127144 }
128145 w .getWorkItems = func (ctx context.Context , args workitemtracking.GetWorkItemsArgs ) (* []workitemtracking.WorkItem , error ) {
0 commit comments