google.golang.org/grpc@v1.72.2/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  	"google.golang.org/grpc/grpclog"
    25  )
    26  
    27  type s struct {
    28  	Tester
    29  }
    30  
    31  func Test(t *testing.T) {
    32  	RunSubTests(t, s{})
    33  }
    34  
    35  func (s) TestInfo(*testing.T) {
    36  	grpclog.Info("Info", "message.")
    37  }
    38  
    39  func (s) TestInfoln(*testing.T) {
    40  	grpclog.Infoln("Info", "message.")
    41  }
    42  
    43  func (s) TestInfof(*testing.T) {
    44  	grpclog.Infof("%v %v.", "Info", "message")
    45  }
    46  
    47  func (s) TestInfoDepth(*testing.T) {
    48  	grpclog.InfoDepth(0, "Info", "depth", "message.")
    49  }
    50  
    51  func (s) TestWarning(*testing.T) {
    52  	grpclog.Warning("Warning", "message.")
    53  }
    54  
    55  func (s) TestWarningln(*testing.T) {
    56  	grpclog.Warningln("Warning", "message.")
    57  }
    58  
    59  func (s) TestWarningf(*testing.T) {
    60  	grpclog.Warningf("%v %v.", "Warning", "message")
    61  }
    62  
    63  func (s) TestWarningDepth(*testing.T) {
    64  	grpclog.WarningDepth(0, "Warning", "depth", "message.")
    65  }
    66  
    67  func (s) TestError(*testing.T) {
    68  	const numErrors = 10
    69  	TLogger.ExpectError("Expected error")
    70  	TLogger.ExpectError("Expected ln error")
    71  	TLogger.ExpectError("Expected formatted error")
    72  	TLogger.ExpectErrorN("Expected repeated error", numErrors)
    73  	grpclog.Error("Expected", "error")
    74  	grpclog.Errorln("Expected", "ln", "error")
    75  	grpclog.Errorf("%v %v %v", "Expected", "formatted", "error")
    76  	for i := 0; i < numErrors; i++ {
    77  		grpclog.Error("Expected repeated error")
    78  	}
    79  }