2015-04-08 15:24:49 +03:00
|
|
|
// 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 (
|
2017-07-05 15:37:28 +03:00
|
|
|
"os"
|
2015-04-08 15:24:49 +03:00
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
2017-07-05 16:05:02 +03:00
|
|
|
os.Setenv(ENV_GIN_MODE, TestMode)
|
2015-04-08 15:24:49 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestSetMode(t *testing.T) {
|
2017-07-05 16:05:02 +03:00
|
|
|
assert.Equal(t, ginMode, testCode)
|
|
|
|
assert.Equal(t, Mode(), TestMode)
|
|
|
|
os.Unsetenv(ENV_GIN_MODE)
|
|
|
|
|
2015-04-08 15:24:49 +03:00
|
|
|
SetMode(DebugMode)
|
|
|
|
assert.Equal(t, ginMode, debugCode)
|
|
|
|
assert.Equal(t, Mode(), DebugMode)
|
|
|
|
|
|
|
|
SetMode(ReleaseMode)
|
|
|
|
assert.Equal(t, ginMode, releaseCode)
|
|
|
|
assert.Equal(t, Mode(), ReleaseMode)
|
|
|
|
|
|
|
|
SetMode(TestMode)
|
|
|
|
assert.Equal(t, ginMode, testCode)
|
|
|
|
assert.Equal(t, Mode(), TestMode)
|
|
|
|
|
|
|
|
assert.Panics(t, func() { SetMode("unknown") })
|
|
|
|
}
|