feat(ci): add a bunch more linters
This commit is contained in:
@@ -30,18 +30,17 @@ const (
|
||||
separator = "-"
|
||||
)
|
||||
|
||||
//nolint:musttag
|
||||
type ID struct {
|
||||
Type IDT
|
||||
Value int
|
||||
}
|
||||
|
||||
func New(in string) (ID, error) {
|
||||
parts := strings.Split(in, separator)
|
||||
if len(parts) != 2 {
|
||||
partType, partValue, ok := strings.Cut(in, separator)
|
||||
if !ok {
|
||||
return ID{}, ErrBadSeparator
|
||||
}
|
||||
partType := parts[0]
|
||||
partValue := parts[1]
|
||||
val, err := strconv.Atoi(partValue)
|
||||
if err != nil {
|
||||
return ID{}, fmt.Errorf("%q: %w", partValue, ErrNotAnInt)
|
||||
|
||||
@@ -6,6 +6,8 @@ import (
|
||||
)
|
||||
|
||||
func TestParseID(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
tcases := []struct {
|
||||
param string
|
||||
expType IDT
|
||||
@@ -20,9 +22,12 @@ func TestParseID(t *testing.T) {
|
||||
{param: "1", expErr: ErrBadSeparator},
|
||||
{param: "al-howdy", expErr: ErrNotAnInt},
|
||||
}
|
||||
|
||||
for _, tcase := range tcases {
|
||||
tcase := tcase // pin
|
||||
t.Run(tcase.param, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
act, err := New(tcase.param)
|
||||
if !errors.Is(err, tcase.expErr) {
|
||||
t.Fatalf("expected err %q, got %q", tcase.expErr, err)
|
||||
|
||||
Reference in New Issue
Block a user