mode_test.go — gin Source File
Architecture documentation for mode_test.go, a go file in the gin codebase. 1 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 3602dea3_53eb_b919_3597_bf86d8085c4a["mode_test.go"] d2008acf_66b7_3bfb_b017_8be29c8c6902["os"] 3602dea3_53eb_b919_3597_bf86d8085c4a --> d2008acf_66b7_3bfb_b017_8be29c8c6902 style 3602dea3_53eb_b919_3597_bf86d8085c4a 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 (
"os"
"sync/atomic"
"testing"
"github.com/gin-gonic/gin/binding"
"github.com/stretchr/testify/assert"
)
func init() {
os.Setenv(EnvGinMode, TestMode)
}
func TestSetMode(t *testing.T) {
assert.Equal(t, int32(testCode), atomic.LoadInt32(&ginMode))
assert.Equal(t, TestMode, Mode())
os.Unsetenv(EnvGinMode)
SetMode("")
assert.Equal(t, int32(testCode), atomic.LoadInt32(&ginMode))
assert.Equal(t, TestMode, Mode())
SetMode(DebugMode)
assert.Equal(t, int32(debugCode), atomic.LoadInt32(&ginMode))
assert.Equal(t, DebugMode, Mode())
SetMode(ReleaseMode)
assert.Equal(t, int32(releaseCode), atomic.LoadInt32(&ginMode))
assert.Equal(t, ReleaseMode, Mode())
SetMode(TestMode)
assert.Equal(t, int32(testCode), atomic.LoadInt32(&ginMode))
assert.Equal(t, TestMode, Mode())
assert.Panics(t, func() { SetMode("unknown") })
}
func TestDisableBindValidation(t *testing.T) {
v := binding.Validator
assert.NotNil(t, binding.Validator)
DisableBindValidation()
assert.Nil(t, binding.Validator)
binding.Validator = v
}
func TestEnableJsonDecoderUseNumber(t *testing.T) {
assert.False(t, binding.EnableDecoderUseNumber)
EnableJsonDecoderUseNumber()
assert.True(t, binding.EnableDecoderUseNumber)
}
func TestEnableJsonDecoderDisallowUnknownFields(t *testing.T) {
assert.False(t, binding.EnableDecoderDisallowUnknownFields)
EnableJsonDecoderDisallowUnknownFields()
assert.True(t, binding.EnableDecoderDisallowUnknownFields)
}
Domain
Subdomains
Functions
Dependencies
- os
Source
Frequently Asked Questions
What does mode_test.go do?
mode_test.go is a source file in the gin codebase, written in go. It belongs to the GinCore domain, Routing subdomain.
What functions are defined in mode_test.go?
mode_test.go defines 5 function(s): TestDisableBindValidation, TestEnableJsonDecoderDisallowUnknownFields, TestEnableJsonDecoderUseNumber, TestSetMode, init.
What does mode_test.go depend on?
mode_test.go imports 1 module(s): os.
Where is mode_test.go in the architecture?
mode_test.go is located at mode_test.go (domain: GinCore, subdomain: Routing).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free