gitee.com/ks-custle/core-gm@v0.0.0-20230922171213-b83bdd97b62c/grpc/internal/grpctest/tlogger_test.go (about) 1 /* 2 * 3 * Copyright 2020 gRPC authors. 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 * 17 */ 18 19 package grpctest 20 21 import ( 22 "testing" 23 24 "gitee.com/ks-custle/core-gm/grpc/grpclog" 25 grpclogi "gitee.com/ks-custle/core-gm/grpc/internal/grpclog" 26 ) 27 28 type s struct { 29 Tester 30 } 31 32 func Test(t *testing.T) { 33 RunSubTests(t, s{}) 34 } 35 36 //goland:noinspection GoUnusedParameter 37 func (s) TestInfo(t *testing.T) { 38 grpclog.Info("Info", "message.") 39 } 40 41 //goland:noinspection GoUnusedParameter 42 func (s) TestInfoln(t *testing.T) { 43 grpclog.Infoln("Info", "message.") 44 } 45 46 //goland:noinspection GoUnusedParameter 47 func (s) TestInfof(t *testing.T) { 48 grpclog.Infof("%v %v.", "Info", "message") 49 } 50 51 //goland:noinspection GoUnusedParameter 52 func (s) TestInfoDepth(t *testing.T) { 53 grpclogi.InfoDepth(0, "Info", "depth", "message.") 54 } 55 56 //goland:noinspection GoUnusedParameter 57 func (s) TestWarning(t *testing.T) { 58 grpclog.Warning("Warning", "message.") 59 } 60 61 //goland:noinspection GoUnusedParameter 62 func (s) TestWarningln(t *testing.T) { 63 grpclog.Warningln("Warning", "message.") 64 } 65 66 //goland:noinspection GoUnusedParameter 67 func (s) TestWarningf(t *testing.T) { 68 grpclog.Warningf("%v %v.", "Warning", "message") 69 } 70 71 //goland:noinspection GoUnusedParameter 72 func (s) TestWarningDepth(t *testing.T) { 73 grpclogi.WarningDepth(0, "Warning", "depth", "message.") 74 } 75 76 //goland:noinspection GoUnusedParameter 77 func (s) TestError(t *testing.T) { 78 const numErrors = 10 79 TLogger.ExpectError("Expected error") 80 TLogger.ExpectError("Expected ln error") 81 TLogger.ExpectError("Expected formatted error") 82 TLogger.ExpectErrorN("Expected repeated error", numErrors) 83 grpclog.Error("Expected", "error") 84 grpclog.Errorln("Expected", "ln", "error") 85 grpclog.Errorf("%v %v %v", "Expected", "formatted", "error") 86 for i := 0; i < numErrors; i++ { 87 grpclog.Error("Expected repeated error") 88 } 89 }