35 lines
780 B
Go
35 lines
780 B
Go
package lexicomai
|
|
|
|
import "testing"
|
|
|
|
func TestNormalizeProduct(t *testing.T) {
|
|
if _, err := NormalizeProduct(""); err == nil {
|
|
t.Error("empty product should error")
|
|
}
|
|
if _, err := NormalizeProduct("nope"); err == nil {
|
|
t.Error("unknown product should error")
|
|
}
|
|
p, err := NormalizeProduct("UPS")
|
|
if err != nil || p != "ups" {
|
|
t.Errorf("NormalizeProduct(UPS) = %q, %v", p, err)
|
|
}
|
|
}
|
|
|
|
func TestServiceUnit(t *testing.T) {
|
|
if got := ServiceUnit("ups"); got != "ups.service" {
|
|
t.Errorf("ServiceUnit = %q", got)
|
|
}
|
|
}
|
|
|
|
func TestDefaultProductsSorted(t *testing.T) {
|
|
ps := DefaultProducts()
|
|
if len(ps) == 0 {
|
|
t.Fatal("DefaultProducts empty")
|
|
}
|
|
for i := 1; i < len(ps); i++ {
|
|
if ps[i] < ps[i-1] {
|
|
t.Errorf("not sorted at %d: %q < %q", i, ps[i], ps[i-1])
|
|
}
|
|
}
|
|
}
|