Repository navigation
Expand file tree
/
Copy pathgmode_test.go
More file actions
61 lines (55 loc) · 1.54 KB
/
Copy pathgmode_test.go
File metadata and controls
61 lines (55 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// Copyright 2020 gf Author(https://github.com/gogf/gf). All Rights Reserved.
//
// 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 (
"github.com/gogf/gf/util/gmode"
"testing"
"github.com/gogf/gf/test/gtest"
)
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)
})
}