1
1
package gateway_test
2
2
3
3
import (
4
- appsv1 "k8s.io/api/apps/v1"
5
- corev1 "k8s.io/api/core/v1"
6
- v1 "k8s.io/api/rbac/v1"
7
- "k8s.io/apimachinery/pkg/runtime"
8
4
"net/http/httptest"
9
5
"os"
10
6
"path/filepath"
7
+ "strings"
11
8
"testing"
12
9
10
+ appsv1 "k8s.io/api/apps/v1"
11
+ corev1 "k8s.io/api/core/v1"
12
+ v1 "k8s.io/api/rbac/v1"
13
+ "k8s.io/apimachinery/pkg/runtime"
14
+
13
15
"github.com/graphql-go/graphql"
14
16
"github.com/openmfp/golang-commons/logger"
15
17
"github.com/stretchr/testify/require"
16
18
"github.com/stretchr/testify/suite"
19
+ "go.uber.org/zap/zapcore"
17
20
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
18
21
"k8s.io/client-go/rest"
19
22
"sigs.k8s.io/controller-runtime/pkg/client"
20
23
"sigs.k8s.io/controller-runtime/pkg/envtest"
21
24
"sigs.k8s.io/controller-runtime/pkg/kcp"
25
+ "sigs.k8s.io/controller-runtime/pkg/log"
26
+ "sigs.k8s.io/controller-runtime/pkg/log/zap"
22
27
23
28
"github.com/openmfp/account-operator/api/v1alpha1"
24
29
appConfig "github.com/openmfp/kubernetes-graphql-gateway/common/config"
@@ -27,6 +32,25 @@ import (
27
32
"github.com/openmfp/kubernetes-graphql-gateway/gateway/schema"
28
33
)
29
34
35
+ func TestMain (m * testing.M ) {
36
+ var zapLevel zapcore.Level
37
+ level := strings .ToUpper (os .Getenv ("LOG_LEVEL" ))
38
+ switch level {
39
+ case "ERROR" :
40
+ zapLevel = zapcore .ErrorLevel
41
+ case "WARN" :
42
+ zapLevel = zapcore .WarnLevel
43
+ case "INFO" :
44
+ zapLevel = zapcore .InfoLevel
45
+ case "DEBUG" , "TRACE" :
46
+ zapLevel = zapcore .DebugLevel
47
+ default :
48
+ zapLevel = zapcore .ErrorLevel
49
+ }
50
+ log .SetLogger (zap .New (zap .UseDevMode (false ), zap .Level (zapLevel )))
51
+ os .Exit (m .Run ())
52
+ }
53
+
30
54
type CommonTestSuite struct {
31
55
suite.Suite
32
56
testEnv * envtest.Environment
0 commit comments