errors_test.go — gin Source File
Architecture documentation for errors_test.go, a go file in the gin codebase. 1 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR bd4678df_f6bd_26e2_4f83_00536939b6d9["errors_test.go"] 285f3da5_b453_bac8_eb53_efea9feb6bb9["errors"] bd4678df_f6bd_26e2_4f83_00536939b6d9 --> 285f3da5_b453_bac8_eb53_efea9feb6bb9 style bd4678df_f6bd_26e2_4f83_00536939b6d9 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
// Copyright 2014 Manu Martinez-Almeida. All rights reserved.
// Use of this source code is governed by a MIT style
// license that can be found in the LICENSE file.
package gin
import (
"errors"
"fmt"
"testing"
"github.com/gin-gonic/gin/codec/json"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestError(t *testing.T) {
baseError := errors.New("test error")
err := &Error{
Err: baseError,
Type: ErrorTypePrivate,
}
assert.Equal(t, err.Error(), baseError.Error())
assert.Equal(t, H{"error": baseError.Error()}, err.JSON())
assert.Equal(t, err.SetType(ErrorTypePublic), err)
assert.Equal(t, ErrorTypePublic, err.Type)
assert.Equal(t, err.SetMeta("some data"), err)
assert.Equal(t, "some data", err.Meta)
assert.Equal(t, H{
"error": baseError.Error(),
"meta": "some data",
}, err.JSON())
jsonBytes, _ := json.API.Marshal(err)
assert.JSONEq(t, "{\"error\":\"test error\",\"meta\":\"some data\"}", string(jsonBytes))
err.SetMeta(H{ //nolint: errcheck
"status": "200",
"data": "some data",
})
assert.Equal(t, H{
"error": baseError.Error(),
"status": "200",
"data": "some data",
}, err.JSON())
err.SetMeta(H{ //nolint: errcheck
"error": "custom error",
"status": "200",
"data": "some data",
})
assert.Equal(t, H{
"error": "custom error",
"status": "200",
"data": "some data",
}, err.JSON())
type customError struct {
// ... (81 more lines)
Domain
Subdomains
Classes
Types
Dependencies
- errors
Source
Frequently Asked Questions
What does errors_test.go do?
errors_test.go is a source file in the gin codebase, written in go. It belongs to the GinCore domain, Middleware subdomain.
What functions are defined in errors_test.go?
errors_test.go defines 3 function(s): TestError, TestErrorSlice, TestErrorUnwrap.
What does errors_test.go depend on?
errors_test.go imports 1 module(s): errors.
Where is errors_test.go in the architecture?
errors_test.go is located at errors_test.go (domain: GinCore, subdomain: Middleware).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free