Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions brew/brew_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ func TestNormalizeName(t *testing.T) {
{"node@18", "node"},
{"go", "go"},
{"ruby@3.2", "ruby"},
{"postgresql@16@beta", "postgresql@16"},
}

b := New()
Expand Down Expand Up @@ -347,6 +348,7 @@ func TestParseVersionSuffix(t *testing.T) {
{"node@18", "node", "18"},
{"git", "git", ""},
{"ruby@3.2", "ruby", "3.2"},
{"postgresql@16@beta", "postgresql@16", "beta"},
{"", "", ""},
{"@3.12", "@3.12", ""}, // @ at position 0, LastIndex returns 0 which is not > 0
}
Expand Down
46 changes: 46 additions & 0 deletions snap/snap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -455,3 +455,49 @@ func TestName(t *testing.T) {
t.Errorf("Name() = %q, want %q", s.Name(), "snap")
}
}

func TestNormalizeName(t *testing.T) {
tests := []struct {
input string
want string
}{
{"firefox", "firefox"},
{"hello-world", "hello-world"},
{"snap.with.dots", "snap.with.dots"},
{" keep-whitespace ", " keep-whitespace "},
{"", ""},
}

s := New()
for _, tt := range tests {
t.Run(tt.input, func(t *testing.T) {
if got := s.NormalizeName(tt.input); got != tt.want {
t.Errorf("NormalizeName(%q) = %q, want %q", tt.input, got, tt.want)
}
})
}
}

func TestParseArch(t *testing.T) {
tests := []struct {
input string
wantName string
wantArch string
}{
{"firefox", "firefox", ""},
{"hello-world", "hello-world", ""},
{"snap.with.dots", "snap.with.dots", ""},
{"", "", ""},
}

s := New()
for _, tt := range tests {
t.Run(tt.input, func(t *testing.T) {
gotName, gotArch := s.ParseArch(tt.input)
if gotName != tt.wantName || gotArch != tt.wantArch {
t.Errorf("ParseArch(%q) = (%q, %q), want (%q, %q)",
tt.input, gotName, gotArch, tt.wantName, tt.wantArch)
}
})
}
}
Loading