Skip to content

Commit

Permalink
Add pagination support to ComponentFirmwareVersion (#227)
Browse files Browse the repository at this point in the history
  • Loading branch information
diogomatsubara authored Aug 16, 2023
1 parent accfa6f commit 84744ff
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
13 changes: 8 additions & 5 deletions pkg/api/v1/firmware_list_params.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@ import (

// ComponentFirmwareVersionListParams allows you to filter the results
type ComponentFirmwareVersionListParams struct {
Vendor string `form:"vendor"`
Model []string `form:"model"`
Version string `form:"version"`
Filename string `form:"filename"`
Checksum string `form:"checksum"`
Vendor string `form:"vendor"`
Model []string `form:"model"`
Version string `form:"version"`
Filename string `form:"filename"`
Checksum string `form:"checksum"`
Pagination *PaginationParams
}

func (p *ComponentFirmwareVersionListParams) setQuery(q url.Values) {
Expand Down Expand Up @@ -44,6 +45,8 @@ func (p *ComponentFirmwareVersionListParams) setQuery(q url.Values) {
if p.Checksum != "" {
q.Set("checksum", p.Checksum)
}

p.Pagination.setQuery(q)
}

// queryMods converts the list params into sql conditions that can be added to sql queries
Expand Down
10 changes: 10 additions & 0 deletions pkg/api/v1/router_firmware_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,16 @@ func TestIntegrationFirmwareList(t *testing.T) {
false,
"",
},
{
"limit results",
&serverservice.ComponentFirmwareVersionListParams{
Vendor: "Dell",
Pagination: &serverservice.PaginationParams{Limit: 1},
},
[]string{dbtools.FixtureDellR640BIOS.ID},
false,
"",
},
}

for _, tt := range testCases {
Expand Down

0 comments on commit 84744ff

Please sign in to comment.