add const

This commit is contained in:
sentriz
2020-04-29 20:10:18 +01:00
committed by Senan Kelly
parent f4a1c3fb0c
commit 26457aae6c
8 changed files with 157 additions and 188 deletions

35
server/ids/ids_test.go Normal file
View File

@@ -0,0 +1,35 @@
package ids
import (
"errors"
"testing"
)
func TestParse(t *testing.T) {
tcases := []struct {
param string
expType ID
expValue int
expErr error
}{
{param: "al-45", expType: Album, expValue: 45},
{param: "ar-2", expType: Artist, expValue: 2},
{param: "tr-43", expType: Track, expValue: 43},
{param: "xx-1", expErr: ErrBadPrefix},
{param: "al-howdy", expErr: ErrNotAnInt},
}
for _, tcase := range tcases {
t.Run(tcase.param, func(t *testing.T) {
act, err := Parse(tcase.param)
if !errors.Is(err, tcase.expErr) {
t.Fatalf("expected err %q, got %q", tcase.expErr, err)
}
if act.Value != tcase.expValue {
t.Errorf("expected value %d, got %d", tcase.expValue, act.Value)
}
if act.Type != tcase.expType {
t.Errorf("expected type %v, got %v", tcase.expType, act.Type)
}
})
}
}