(t *testing.T)
| 132 | } |
| 133 | |
| 134 | func (s) TestRetryChainedInterceptor(t *testing.T) { |
| 135 | var records []int |
| 136 | i1 := func(ctx context.Context, req any, _ *UnaryServerInfo, handler UnaryHandler) (resp any, err error) { |
| 137 | records = append(records, 1) |
| 138 | // call handler twice to simulate a retry here. |
| 139 | handler(ctx, req) |
| 140 | return handler(ctx, req) |
| 141 | } |
| 142 | i2 := func(ctx context.Context, req any, _ *UnaryServerInfo, handler UnaryHandler) (resp any, err error) { |
| 143 | records = append(records, 2) |
| 144 | return handler(ctx, req) |
| 145 | } |
| 146 | i3 := func(ctx context.Context, req any, _ *UnaryServerInfo, handler UnaryHandler) (resp any, err error) { |
| 147 | records = append(records, 3) |
| 148 | return handler(ctx, req) |
| 149 | } |
| 150 | |
| 151 | ii := chainUnaryInterceptors([]UnaryServerInterceptor{i1, i2, i3}) |
| 152 | |
| 153 | handler := func(context.Context, any) (any, error) { |
| 154 | return nil, nil |
| 155 | } |
| 156 | |
| 157 | ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout) |
| 158 | defer cancel() |
| 159 | |
| 160 | ii(ctx, nil, nil, handler) |
| 161 | if !cmp.Equal(records, []int{1, 2, 3, 2, 3}) { |
| 162 | t.Fatalf("retry failed on chained interceptors: %v", records) |
| 163 | } |
| 164 | } |
| 165 | |
| 166 | func (s) TestStreamContext(t *testing.T) { |
| 167 | expectedStream := &transport.ServerStream{} |
nothing calls this directly
no test coverage detected