github.com/hxx258456/ccgo@v0.0.5-0.20230213014102-48b35f46f66f/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 "github.com/hxx258456/ccgo/grpc/grpclog" 25 grpclogi "github.com/hxx258456/ccgo/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 func (s) TestInfo(t *testing.T) { 37 grpclog.Info("Info", "message.") 38 } 39 40 func (s) TestInfoln(t *testing.T) { 41 grpclog.Infoln("Info", "message.") 42 } 43 44 func (s) TestInfof(t *testing.T) { 45 grpclog.Infof("%v %v.", "Info", "message") 46 } 47 48 func (s) TestInfoDepth(t *testing.T) { 49 grpclogi.InfoDepth(0, "Info", "depth", "message.") 50 } 51 52 func (s) TestWarning(t *testing.T) { 53 grpclog.Warning("Warning", "message.") 54 } 55 56 func (s) TestWarningln(t *testing.T) { 57 grpclog.Warningln("Warning", "message.") 58 } 59 60 func (s) TestWarningf(t *testing.T) { 61 grpclog.Warningf("%v %v.", "Warning", "message") 62 } 63 64 func (s) TestWarningDepth(t *testing.T) { 65 grpclogi.WarningDepth(0, "Warning", "depth", "message.") 66 } 67 68 func (s) TestError(t *testing.T) { 69 const numErrors = 10 70 TLogger.ExpectError("Expected error") 71 TLogger.ExpectError("Expected ln error") 72 TLogger.ExpectError("Expected formatted error") 73 TLogger.ExpectErrorN("Expected repeated error", numErrors) 74 grpclog.Error("Expected", "error") 75 grpclog.Errorln("Expected", "ln", "error") 76 grpclog.Errorf("%v %v %v", "Expected", "formatted", "error") 77 for i := 0; i < numErrors; i++ { 78 grpclog.Error("Expected repeated error") 79 } 80 }