add test case of mode

This commit is contained in:
thinkerou 2017-07-05 21:05:02 +08:00
parent 2a36eefcff
commit f843c33370
1 changed files with 5 additions and 6 deletions

View File

@ -12,10 +12,14 @@ import (
)
func init() {
SetMode(TestMode)
os.Setenv(ENV_GIN_MODE, TestMode)
}
func TestSetMode(t *testing.T) {
assert.Equal(t, ginMode, testCode)
assert.Equal(t, Mode(), TestMode)
os.Unsetenv(ENV_GIN_MODE)
SetMode(DebugMode)
assert.Equal(t, ginMode, debugCode)
assert.Equal(t, Mode(), DebugMode)
@ -29,9 +33,4 @@ func TestSetMode(t *testing.T) {
assert.Equal(t, Mode(), TestMode)
assert.Panics(t, func() { SetMode("unknown") })
os.Setenv(ENV_GIN_MODE, DebugMode)
assert.Equal(t, ginMode, debugCode)
assert.Equal(t, Mode(), DebugMode)
os.Unsetenv(ENV_GIN_MODE)
}