Commit 53f489f8 authored by Patrick Rice's avatar Patrick Rice 🫖
Browse files

Merge branch 'mohamedmongy96-main-patch-37451' into 'main'

Add missing query params to ListGroupsOptions

See merge request !2726
parents d4149bcd a16fd017
Loading
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -253,6 +253,9 @@ type ListGroupsOptions struct {
	MinAccessLevel       *AccessLevelValue `url:"min_access_level,omitempty" json:"min_access_level,omitempty"`
	TopLevelOnly         *bool             `url:"top_level_only,omitempty" json:"top_level_only,omitempty"`
	RepositoryStorage    *string           `url:"repository_storage,omitempty" json:"repository_storage,omitempty"`
	MarkedForDeletionOn  *ISOTime          `url:"marked_for_deletion_on,omitempty" json:"marked_for_deletion_on,omitempty"`
	Active               *bool             `url:"active,omitempty" json:"active,omitempty"`
	Archived             *bool             `url:"archived,omitempty" json:"archived,omitempty"`
}

// ListGroups gets a list of groups (as user: my groups, as admin: all groups).
+35 −0
Original line number Diff line number Diff line
@@ -38,6 +38,41 @@ func TestListGroups(t *testing.T) {
	}
}

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

	mux.HandleFunc("/api/v4/groups", func(w http.ResponseWriter, r *http.Request) {
		testMethod(t, r, http.MethodGet)

		testParam(t, r, "active", "true")
		testParam(t, r, "archived", "false")
		testParam(t, r, "marked_for_deletion_on", "2023-10-01")

		fmt.Fprint(w, `[{"id":1}]`)
	})

	active := true
	archived := false
	deletionDate := ISOTime(time.Date(2023, time.October, 1, 0, 0, 0, 0, time.UTC))

	opt := &ListGroupsOptions{
		Active:              &active,
		Archived:            &archived,
		MarkedForDeletionOn: &deletionDate,
	}

	groups, _, err := client.Groups.ListGroups(opt)
	if err != nil {
		t.Errorf("Groups.ListGroups returned error: %v", err)
	}

	want := []*Group{{ID: 1}}
	if !reflect.DeepEqual(want, groups) {
		t.Errorf("Groups.ListGroups returned %+v, want %+v", groups, want)
	}
}

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