Skip to content

Commit 19bb6fc

Browse files
committed
Add enums to sort by browser feature support
1 parent 1455feb commit 19bb6fc

File tree

3 files changed

+58
-1
lines changed

3 files changed

+58
-1
lines changed

lib/gcpspanner/spanneradapters/backend.go

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -555,12 +555,13 @@ func (s *Backend) FeaturesSearch(
555555
}
556556

557557
// TODO: Pass in context to be used by slog.ErrorContext.
558+
// nolint: gocyclo // WONTFIX. Keep all the cases here so that the exhaustive
559+
// linter can catch a missing case.
558560
func getFeatureSearchSortOrder(
559561
sortOrder *backend.ListFeaturesParamsSort) gcpspanner.Sortable {
560562
if sortOrder == nil {
561563
return gcpspanner.NewBaselineStatusSort(false)
562564
}
563-
// nolint: exhaustive // Remove once we support all the cases.
564565
switch *sortOrder {
565566
case backend.NameAsc:
566567
return gcpspanner.NewFeatureNameSort(true)
@@ -606,6 +607,22 @@ func getFeatureSearchSortOrder(
606607
return gcpspanner.NewChromiumUsageSort(true)
607608
case backend.ChromiumUsageDesc:
608609
return gcpspanner.NewChromiumUsageSort(false)
610+
case backend.DesktopAvailabilityChromeAsc:
611+
return gcpspanner.NewBrowserFeatureSupportSort(true, string(backend.Chrome))
612+
case backend.DesktopAvailabilityChromeDesc:
613+
return gcpspanner.NewBrowserFeatureSupportSort(false, string(backend.Chrome))
614+
case backend.DesktopAvailabilityEdgeAsc:
615+
return gcpspanner.NewBrowserFeatureSupportSort(true, string(backend.Edge))
616+
case backend.DesktopAvailabilityEdgeDesc:
617+
return gcpspanner.NewBrowserFeatureSupportSort(false, string(backend.Edge))
618+
case backend.DesktopAvailabilityFirefoxAsc:
619+
return gcpspanner.NewBrowserFeatureSupportSort(true, string(backend.Firefox))
620+
case backend.DesktopAvailabilityFirefoxDesc:
621+
return gcpspanner.NewBrowserFeatureSupportSort(false, string(backend.Firefox))
622+
case backend.DesktopAvailabilitySafariAsc:
623+
return gcpspanner.NewBrowserFeatureSupportSort(true, string(backend.Safari))
624+
case backend.DesktopAvailabilitySafariDesc:
625+
return gcpspanner.NewBrowserFeatureSupportSort(false, string(backend.Safari))
609626
}
610627

611628
// Unknown sort order

lib/gcpspanner/spanneradapters/backend_test.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1336,6 +1336,38 @@ func TestGetFeatureSearchSortOrder(t *testing.T) {
13361336
input: valuePtr(backend.StableSafariDesc),
13371337
want: gcpspanner.NewBrowserImplSort(false, "safari", true),
13381338
},
1339+
{
1340+
input: valuePtr(backend.DesktopAvailabilityChromeAsc),
1341+
want: gcpspanner.NewBrowserFeatureSupportSort(true, "chrome"),
1342+
},
1343+
{
1344+
input: valuePtr(backend.DesktopAvailabilityChromeDesc),
1345+
want: gcpspanner.NewBrowserFeatureSupportSort(false, "chrome"),
1346+
},
1347+
{
1348+
input: valuePtr(backend.DesktopAvailabilityEdgeAsc),
1349+
want: gcpspanner.NewBrowserFeatureSupportSort(true, "edge"),
1350+
},
1351+
{
1352+
input: valuePtr(backend.DesktopAvailabilityEdgeDesc),
1353+
want: gcpspanner.NewBrowserFeatureSupportSort(false, "edge"),
1354+
},
1355+
{
1356+
input: valuePtr(backend.DesktopAvailabilityFirefoxAsc),
1357+
want: gcpspanner.NewBrowserFeatureSupportSort(true, "firefox"),
1358+
},
1359+
{
1360+
input: valuePtr(backend.DesktopAvailabilityFirefoxDesc),
1361+
want: gcpspanner.NewBrowserFeatureSupportSort(false, "firefox"),
1362+
},
1363+
{
1364+
input: valuePtr(backend.DesktopAvailabilitySafariAsc),
1365+
want: gcpspanner.NewBrowserFeatureSupportSort(true, "safari"),
1366+
},
1367+
{
1368+
input: valuePtr(backend.DesktopAvailabilitySafariDesc),
1369+
want: gcpspanner.NewBrowserFeatureSupportSort(false, "safari"),
1370+
},
13391371
}
13401372

13411373
for _, tt := range sortOrderTests {

openapi/backend/openapi.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,14 @@ paths:
7676
- experimental_firefox_desc
7777
- chromium_usage_asc
7878
- chromium_usage_desc
79+
- desktop_availability_chrome_asc
80+
- desktop_availability_chrome_desc
81+
- desktop_availability_edge_asc
82+
- desktop_availability_edge_desc
83+
- desktop_availability_firefox_asc
84+
- desktop_availability_firefox_desc
85+
- desktop_availability_safari_asc
86+
- desktop_availability_safari_desc
7987
responses:
8088
'200':
8189
description: OK

0 commit comments

Comments
 (0)