2021-01-17 21:46:25 +08:00
|
|
|
// Copyright GoFrame Author(https://goframe.org). All Rights Reserved.
|
2020-07-12 09:34:43 +08:00
|
|
|
//
|
|
|
|
// This Source Code Form is subject to the terms of the MIT License.
|
|
|
|
// If a copy of the MIT was not distributed with this file,
|
|
|
|
// You can obtain one at https://github.com/gogf/gf.
|
|
|
|
|
|
|
|
// go test *.go -bench=".*"
|
|
|
|
|
|
|
|
package gmode_test
|
|
|
|
|
|
|
|
import (
|
2021-10-11 21:41:56 +08:00
|
|
|
"github.com/gogf/gf/v2/util/gmode"
|
2020-07-12 09:34:43 +08:00
|
|
|
"testing"
|
|
|
|
|
2021-10-11 21:41:56 +08:00
|
|
|
"github.com/gogf/gf/v2/test/gtest"
|
2020-07-12 09:34:43 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
func Test_AutoCheckSourceCodes(t *testing.T) {
|
|
|
|
gtest.C(t, func(t *gtest.T) {
|
|
|
|
t.Assert(gmode.IsDevelop(), true)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func Test_Set(t *testing.T) {
|
|
|
|
gtest.C(t, func(t *gtest.T) {
|
|
|
|
oldMode := gmode.Mode()
|
|
|
|
defer gmode.Set(oldMode)
|
|
|
|
gmode.SetDevelop()
|
|
|
|
t.Assert(gmode.IsDevelop(), true)
|
|
|
|
t.Assert(gmode.IsTesting(), false)
|
|
|
|
t.Assert(gmode.IsStaging(), false)
|
|
|
|
t.Assert(gmode.IsProduct(), false)
|
|
|
|
})
|
|
|
|
gtest.C(t, func(t *gtest.T) {
|
|
|
|
oldMode := gmode.Mode()
|
|
|
|
defer gmode.Set(oldMode)
|
|
|
|
gmode.SetTesting()
|
|
|
|
t.Assert(gmode.IsDevelop(), false)
|
|
|
|
t.Assert(gmode.IsTesting(), true)
|
|
|
|
t.Assert(gmode.IsStaging(), false)
|
|
|
|
t.Assert(gmode.IsProduct(), false)
|
|
|
|
})
|
|
|
|
gtest.C(t, func(t *gtest.T) {
|
|
|
|
oldMode := gmode.Mode()
|
|
|
|
defer gmode.Set(oldMode)
|
|
|
|
gmode.SetStaging()
|
|
|
|
t.Assert(gmode.IsDevelop(), false)
|
|
|
|
t.Assert(gmode.IsTesting(), false)
|
|
|
|
t.Assert(gmode.IsStaging(), true)
|
|
|
|
t.Assert(gmode.IsProduct(), false)
|
|
|
|
})
|
|
|
|
gtest.C(t, func(t *gtest.T) {
|
|
|
|
oldMode := gmode.Mode()
|
|
|
|
defer gmode.Set(oldMode)
|
|
|
|
gmode.SetProduct()
|
|
|
|
t.Assert(gmode.IsDevelop(), false)
|
|
|
|
t.Assert(gmode.IsTesting(), false)
|
|
|
|
t.Assert(gmode.IsStaging(), false)
|
|
|
|
t.Assert(gmode.IsProduct(), true)
|
|
|
|
})
|
|
|
|
}
|