feat(ci): add a bunch more linters

This commit is contained in:
sentriz
2023-09-22 19:05:20 +02:00
parent 33f1f2e0cf
commit e3dd812b6c
37 changed files with 233 additions and 139 deletions

View File

@@ -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)

View File

@@ -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)