From f843c333702ca0c52b6170b34b5b514f7e530521 Mon Sep 17 00:00:00 2001 From: thinkerou Date: Wed, 5 Jul 2017 21:05:02 +0800 Subject: [PATCH] add test case of mode --- mode_test.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/mode_test.go b/mode_test.go index bf6a5a1a..0a9cbc3c 100644 --- a/mode_test.go +++ b/mode_test.go @@ -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) }