1
0
mirror of https://github.com/gofiber/fiber.git synced 2025-02-21 04:33:03 +00:00

fix unhandled error in cache package tests (#2049)

* 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
This commit is contained in:
Amir Hossein 2022-08-26 16:40:46 +04:30 committed by GitHub
parent 01ea139da4
commit ffb2d4cb1a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 12 deletions

View File

@ -44,8 +44,8 @@ func (c *Connection) Release() {
// Load COM object from list of programIDs or strings.
func (c *Connection) Load(names ...string) (errors []error) {
var tempErrors []error = make([]error, len(names))
var numErrors int = 0
var tempErrors = make([]error, len(names))
var numErrors = 0
for _, name := range names {
err := c.Create(name)
if err != nil {

View File

@ -74,19 +74,19 @@ func (d *Decoder) Decode(dst interface{}, src map[string][]string) error {
}
v = v.Elem()
t := v.Type()
errors := MultiError{}
multiError := MultiError{}
for path, values := range src {
if parts, err := d.cache.parsePath(path, t); err == nil {
if err = d.decode(v, path, parts, values); err != nil {
errors[path] = err
multiError[path] = err
}
} else if !d.ignoreUnknownKeys {
errors[path] = UnknownKeyError{Key: path}
multiError[path] = UnknownKeyError{Key: path}
}
}
errors.merge(d.checkRequired(t, src))
if len(errors) > 0 {
return errors
multiError.merge(d.checkRequired(t, src))
if len(multiError) > 0 {
return multiError
}
return nil
}

View File

@ -5,6 +5,7 @@ package cache
import (
"bytes"
"fmt"
"io"
"io/ioutil"
"math"
"net/http"
@ -126,7 +127,10 @@ func Test_Cache_WithSeveralRequests(t *testing.T) {
rsp, err := app.Test(httptest.NewRequest(http.MethodGet, fmt.Sprintf("/%d", id), nil))
utils.AssertEqual(t, nil, err)
defer rsp.Body.Close()
defer func(Body io.ReadCloser) {
err := Body.Close()
utils.AssertEqual(t, nil, err)
}(rsp.Body)
idFromServ, err := ioutil.ReadAll(rsp.Body)
utils.AssertEqual(t, nil, err)

View File

@ -127,9 +127,9 @@ func Test_Session_Types(t *testing.T) {
Name: "John",
}
// set value
var vbool bool = true
var vstring string = "str"
var vint int = 13
var vbool = true
var vstring = "str"
var vint = 13
var vint8 int8 = 13
var vint16 int16 = 13
var vint32 int32 = 13