Skip to content

Commit bac4f9e

Browse files
author
dhruv
committed
fix: [CDE-997]: Updating test.
1 parent ebf056b commit bac4f9e

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

scm/driver/harness/repo.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,13 @@ func (s *repositoryService) ListHooks(ctx context.Context, repo string, opts scm
9696
if err != nil {
9797
return nil, nil, err
9898
}
99-
path := fmt.Sprintf("api/v1/repos/%s/webhooks?sort=display_name&order=asc&%s&%s", repoId, encodeListOptions(opts), queryParams)
99+
if opts.SortKey == "" {
100+
opts.SortKey = "display_name"
101+
}
102+
if opts.Order == "" {
103+
opts.Order = "asc"
104+
}
105+
path := fmt.Sprintf("api/v1/repos/%s/webhooks?%s&%s", repoId, encodeListOptions(opts), queryParams)
100106
out := []*hook{}
101107
res, err := s.client.do(ctx, "GET", path, nil, &out)
102108
return convertHookList(out), res, err

scm/driver/harness/util_test.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@ import (
1212

1313
func Test_encodeListOptions(t *testing.T) {
1414
opts := scm.ListOptions{
15-
Page: 10,
16-
Size: 30,
15+
Page: 10,
16+
Size: 30,
17+
SortKey: "date",
18+
Order: "asc",
1719
}
18-
want := "limit=30&page=10"
20+
want := "limit=30&order=asc&page=10&sort=date"
1921
got := encodeListOptions(opts)
2022
if got != want {
2123
t.Errorf("Want encoded list options %q, got %q", want, got)

0 commit comments

Comments
 (0)