Skip to content

Commit aaf411b

Browse files
committed
Test and enforce alphabetical sorting of fun categories and packages
1 parent 4db5986 commit aaf411b

File tree

2 files changed

+31
-3
lines changed

2 files changed

+31
-3
lines changed

internal/ui/fun/config.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ var Categories = []Category{
99
{
1010
Name: "Browsers",
1111
Packages: []string{
12-
"angelfish", "brave-bin", "chromium", "dillo", "eolie", "epiphany", "elinks",
12+
"angelfish", "brave-bin", "chromium", "dillo", "elinks", "eolie", "epiphany",
1313
"falkon", "firefox", "firefox-developer-edition", "google-chrome", "helium-browser-bin",
1414
"konqueror", "links", "lynx", "netsurf", "nyxt", "opera", "qutebrowser",
1515
"torbrowser-launcher", "vimb", "vivaldi", "w3m",
@@ -27,8 +27,8 @@ var Categories = []Category{
2727
{
2828
Name: "Editors",
2929
Packages: []string{
30-
"code", "e3", "ed", "emacs", "geany", "gedit", "helix", "kakoune", "kate",
31-
"gnome-text-editor", "gobby", "leafpad", "micro", "mousepad", "nano", "neovim",
30+
"code", "e3", "ed", "emacs", "geany", "gedit", "gnome-text-editor", "gobby",
31+
"helix", "kakoune", "kate", "leafpad", "micro", "mousepad", "nano", "neovim",
3232
"notepadqq", "orbiton", "orbiton-nano", "scite", "vi", "vim", "vis", "xed", "zed",
3333
},
3434
},

internal/ui/fun/config_test.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package fun
2+
3+
import (
4+
"slices"
5+
"testing"
6+
)
7+
8+
func TestCategoriesAreSorted(t *testing.T) {
9+
if !slices.IsSortedFunc(Categories, func(a, b Category) int {
10+
if a.Name < b.Name {
11+
return -1
12+
}
13+
if a.Name > b.Name {
14+
return 1
15+
}
16+
return 0
17+
}) {
18+
t.Error("Categories must be sorted alphabetically by Name")
19+
}
20+
}
21+
22+
func TestPackagesAreSorted(t *testing.T) {
23+
for _, cat := range Categories {
24+
if !slices.IsSorted(cat.Packages) {
25+
t.Errorf("Packages in category %q must be sorted alphabetically", cat.Name)
26+
}
27+
}
28+
}

0 commit comments

Comments
 (0)