Verified Commit d1723072 authored by Timo Furrer's avatar Timo Furrer ☕ Committed by GitLab
Browse files

Merge branch 'auto_complete' into 'main'

feat(projects): add topic_id, updated_after and updated_before to ListProjectsOptions

See merge request !3084
parents b0372eda 92dd2ba6
Loading
Loading
Loading
Loading
Loading
+3
Changes for projects.go: 3 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -757,6 +757,9 @@ type ListProjectsOptions struct {
	Starred                  *bool             `url:"starred,omitempty" json:"starred,omitempty"`
	Statistics               *bool             `url:"statistics,omitempty" json:"statistics,omitempty"`
	Topic                    *string           `url:"topic,omitempty" json:"topic,omitempty"`
	TopicID                  *int64            `url:"topic_id,omitempty" json:"topic_id,omitempty"`
	UpdatedAfter             *time.Time        `url:"updated_after,omitempty" json:"updated_after,omitempty"`
	UpdatedBefore            *time.Time        `url:"updated_before,omitempty" json:"updated_before,omitempty"`
	Visibility               *VisibilityValue  `url:"visibility,omitempty" json:"visibility,omitempty"`
	WikiChecksumFailed       *bool             `url:"wiki_checksum_failed,omitempty" json:"wiki_checksum_failed,omitempty"`
	WithCustomAttributes     *bool             `url:"with_custom_attributes,omitempty" json:"with_custom_attributes,omitempty"`
+27
Changes for projects_test.go: 27 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -123,6 +123,33 @@ func TestListProjects(t *testing.T) {
	}
}

func TestListProjects_TopicIDAndUpdatedFilters(t *testing.T) {
	t.Parallel()
	mux, client := setup(t)

	// GIVEN a server that expects the topic ID and updated time filters
	mux.HandleFunc("/api/v4/projects", func(w http.ResponseWriter, r *http.Request) {
		testMethod(t, r, http.MethodGet)
		testParam(t, r, "topic_id", "42")
		testParam(t, r, "updated_after", "2026-01-01T00:00:00Z")
		testParam(t, r, "updated_before", "2026-02-01T00:00:00Z")
		testParam(t, r, "order_by", "updated_at")
		mustWriteJSONResponse(t, w, []map[string]any{{"id": 1}})
	})

	// WHEN listing projects with those filters
	projects, _, err := client.Projects.ListProjects(&ListProjectsOptions{
		OrderBy:       new("updated_at"),
		TopicID:       new(int64(42)),
		UpdatedAfter:  mustParseTime("2026-01-01T00:00:00Z"),
		UpdatedBefore: mustParseTime("2026-02-01T00:00:00Z"),
	})

	// THEN the filters are sent and the projects are returned
	require.NoError(t, err)
	assert.Equal(t, []*Project{{ID: 1}}, projects)
}

func TestListProjects_CustomAttributesFiltering(t *testing.T) {
	t.Parallel()
	mux, client := setup(t)