Loading workitems.go +4 −4 Original line number Diff line number Diff line Loading @@ -1015,7 +1015,7 @@ type workItemCreateInputGQL struct { // workItemWidgetAssigneesInputGQL represents the assignees widget input. type workItemWidgetAssigneesInputGQL struct { AssigneeIDs []string `json:"assigneeIds,omitempty"` AssigneeIDs []string `json:"assigneeIds"` } // workItemWidgetDescriptionInputGQL represents the description widget input. Loading Loading @@ -1077,7 +1077,7 @@ type workItemWidgetColorInputGQL struct { // workItemWidgetCRMContactsUpdateInputGQL represents the CRM contacts widget input for updates. type workItemWidgetCRMContactsUpdateInputGQL struct { ContactIDs []string `json:"contactIds,omitempty"` ContactIDs []string `json:"contactIds"` OperationMode *string `json:"operationMode,omitempty"` } Loading Loading @@ -1372,7 +1372,7 @@ func (opt *UpdateWorkItemOptions) wrap(gid gidGQL) *workItemUpdateInputGQL { } } if len(opt.AssigneeIDs) > 0 { if opt.AssigneeIDs != nil { input.AssigneesWidget = &workItemWidgetAssigneesInputGQL{ AssigneeIDs: newGIDStrings("User", opt.AssigneeIDs...), } Loading @@ -1384,7 +1384,7 @@ func (opt *UpdateWorkItemOptions) wrap(gid gidGQL) *workItemUpdateInputGQL { } } if len(opt.CRMContactIDs) > 0 { if opt.CRMContactIDs != nil { input.CRMContactsWidget = &workItemWidgetCRMContactsUpdateInputGQL{ ContactIDs: newGIDStrings("CustomerRelations::Contact", opt.CRMContactIDs...), OperationMode: Ptr("REPLACE"), Loading workitems_test.go +44 −0 Original line number Diff line number Diff line Loading @@ -1233,6 +1233,50 @@ func TestUpdateWorkItem_SuccessfulUpdateWithAllOptions(t *testing.T) { }, got) } func TestUpdateWorkItem_EmptySlicesClearAssigneesAndCRMContacts(t *testing.T) { t.Parallel() mux, client := setup(t) var gotInput map[string]any // GIVEN an UpdateWorkItem request that clears assignees and CRM contacts setupGraphQLHandler(t, mux, func(w http.ResponseWriter, q GraphQLQuery) { // the client first resolves the iid to a global ID if strings.Contains(q.Query, "GetWorkItemID") { io.WriteString(w, `{"data":{"namespace":{"workItem":{"id":"gid://gitlab/WorkItem/179785913"}}}}`) return } gotInput, _ = q.Variables["input"].(map[string]any) writeResponse(t, w, bytes.NewReader(updateWorkItemResponse)) }) // WHEN UpdateWorkItem is called with empty non-nil slices got, _, err := client.WorkItems.UpdateWorkItem( "testing/unittest", 117869168, &UpdateWorkItemOptions{ AssigneeIDs: []int64{}, CRMContactIDs: []int64{}, }, ) // THEN both assignees and CRM contacts are cleared require.NoError(t, err) require.NotNil(t, got) require.NotNil(t, gotInput) assert.Equal(t, map[string]any{ "assigneeIds": []any{}, }, gotInput["assigneesWidget"]) assert.Equal(t, map[string]any{ "contactIds": []any{}, "operationMode": "REPLACE", }, gotInput["crmContactsWidget"]) } func TestUpdateWorkItem_WorkItemNotFoundDuringIDLookup(t *testing.T) { t.Parallel() Loading Loading
workitems.go +4 −4 Original line number Diff line number Diff line Loading @@ -1015,7 +1015,7 @@ type workItemCreateInputGQL struct { // workItemWidgetAssigneesInputGQL represents the assignees widget input. type workItemWidgetAssigneesInputGQL struct { AssigneeIDs []string `json:"assigneeIds,omitempty"` AssigneeIDs []string `json:"assigneeIds"` } // workItemWidgetDescriptionInputGQL represents the description widget input. Loading Loading @@ -1077,7 +1077,7 @@ type workItemWidgetColorInputGQL struct { // workItemWidgetCRMContactsUpdateInputGQL represents the CRM contacts widget input for updates. type workItemWidgetCRMContactsUpdateInputGQL struct { ContactIDs []string `json:"contactIds,omitempty"` ContactIDs []string `json:"contactIds"` OperationMode *string `json:"operationMode,omitempty"` } Loading Loading @@ -1372,7 +1372,7 @@ func (opt *UpdateWorkItemOptions) wrap(gid gidGQL) *workItemUpdateInputGQL { } } if len(opt.AssigneeIDs) > 0 { if opt.AssigneeIDs != nil { input.AssigneesWidget = &workItemWidgetAssigneesInputGQL{ AssigneeIDs: newGIDStrings("User", opt.AssigneeIDs...), } Loading @@ -1384,7 +1384,7 @@ func (opt *UpdateWorkItemOptions) wrap(gid gidGQL) *workItemUpdateInputGQL { } } if len(opt.CRMContactIDs) > 0 { if opt.CRMContactIDs != nil { input.CRMContactsWidget = &workItemWidgetCRMContactsUpdateInputGQL{ ContactIDs: newGIDStrings("CustomerRelations::Contact", opt.CRMContactIDs...), OperationMode: Ptr("REPLACE"), Loading
workitems_test.go +44 −0 Original line number Diff line number Diff line Loading @@ -1233,6 +1233,50 @@ func TestUpdateWorkItem_SuccessfulUpdateWithAllOptions(t *testing.T) { }, got) } func TestUpdateWorkItem_EmptySlicesClearAssigneesAndCRMContacts(t *testing.T) { t.Parallel() mux, client := setup(t) var gotInput map[string]any // GIVEN an UpdateWorkItem request that clears assignees and CRM contacts setupGraphQLHandler(t, mux, func(w http.ResponseWriter, q GraphQLQuery) { // the client first resolves the iid to a global ID if strings.Contains(q.Query, "GetWorkItemID") { io.WriteString(w, `{"data":{"namespace":{"workItem":{"id":"gid://gitlab/WorkItem/179785913"}}}}`) return } gotInput, _ = q.Variables["input"].(map[string]any) writeResponse(t, w, bytes.NewReader(updateWorkItemResponse)) }) // WHEN UpdateWorkItem is called with empty non-nil slices got, _, err := client.WorkItems.UpdateWorkItem( "testing/unittest", 117869168, &UpdateWorkItemOptions{ AssigneeIDs: []int64{}, CRMContactIDs: []int64{}, }, ) // THEN both assignees and CRM contacts are cleared require.NoError(t, err) require.NotNil(t, got) require.NotNil(t, gotInput) assert.Equal(t, map[string]any{ "assigneeIds": []any{}, }, gotInput["assigneesWidget"]) assert.Equal(t, map[string]any{ "contactIds": []any{}, "operationMode": "REPLACE", }, gotInput["crmContactsWidget"]) } func TestUpdateWorkItem_WorkItemNotFoundDuringIDLookup(t *testing.T) { t.Parallel() Loading