Skip to content

Commit

Permalink
unhandled error in hooks test (#2070)
Browse files Browse the repository at this point in the history
* fix unhandled errors

* fix unhandled error in cache package test

* omit variable type

* omit variable type

* rename variable because collide with the imported package name

* handle file error on closing

* fix unhandled in common_linux.go

* fix unhandled errors in helpers_test.go

* fix unhandled errors in listen_test.go

* remove unused parameter in emptyHandler method

* refactor path.go

* unhandled error in hooks test
  • Loading branch information
Kamandlou committed Sep 2, 2022
1 parent 1f18ae3 commit b7500a8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
16 changes: 10 additions & 6 deletions hooks_test.go
Expand Up @@ -42,7 +42,8 @@ func Test_Hook_OnName(t *testing.T) {
defer bytebufferpool.Put(buf)

app.Hooks().OnName(func(r Route) error {
buf.WriteString(r.Name)
_, err := buf.WriteString(r.Name)
utils.AssertEqual(t, nil, err)

return nil
})
Expand Down Expand Up @@ -84,8 +85,8 @@ func Test_Hook_OnGroup(t *testing.T) {
defer bytebufferpool.Put(buf)

app.Hooks().OnGroup(func(g Group) error {
buf.WriteString(g.Prefix)

_, err := buf.WriteString(g.Prefix)
utils.AssertEqual(t, nil, err)
return nil
})

Expand All @@ -104,7 +105,8 @@ func Test_Hook_OnGroupName(t *testing.T) {
defer bytebufferpool.Put(buf)

app.Hooks().OnGroupName(func(g Group) error {
buf.WriteString(g.name)
_, err := buf.WriteString(g.name)
utils.AssertEqual(t, nil, err)

return nil
})
Expand Down Expand Up @@ -143,7 +145,8 @@ func Test_Hook_OnShutdown(t *testing.T) {
defer bytebufferpool.Put(buf)

app.Hooks().OnShutdown(func() error {
buf.WriteString("shutdowning")
_, err := buf.WriteString("shutdowning")
utils.AssertEqual(t, nil, err)

return nil
})
Expand All @@ -163,7 +166,8 @@ func Test_Hook_OnListen(t *testing.T) {
defer bytebufferpool.Put(buf)

app.Hooks().OnListen(func() error {
buf.WriteString("ready")
_, err := buf.WriteString("ready")
utils.AssertEqual(t, nil, err)

return nil
})
Expand Down
4 changes: 2 additions & 2 deletions path.go
Expand Up @@ -60,7 +60,7 @@ const (
paramConstraintDataSeparator byte = ',' // separator of datas of type constraint for a parameter
)

// parameter constraint types
// TypeConstraint parameter constraint types
type TypeConstraint int16

type Constraint struct {
Expand Down Expand Up @@ -259,7 +259,7 @@ func (routeParser *routeParser) analyseParameterPart(pattern string) (string, *r
// Check has constraint
var constraints []*Constraint

if hasConstraint := (parameterConstraintStart != -1 && parameterConstraintEnd != -1); hasConstraint {
if hasConstraint := parameterConstraintStart != -1 && parameterConstraintEnd != -1; hasConstraint {
constraintString := pattern[parameterConstraintStart+1 : parameterConstraintEnd]
userConstraints := splitNonEscaped(constraintString, string(parameterConstraintSeparatorChars))
constraints = make([]*Constraint, 0, len(userConstraints))
Expand Down

0 comments on commit b7500a8

Please sign in to comment.