MCPcopy
hub / github.com/grpc/grpc-go / TestEncodingRequiredStatus

Method TestEncodingRequiredStatus

internal/transport/transport_test.go:1683–1711  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1681var encodingTestStatus = status.New(codes.Internal, "\n")
1682
1683func (s) TestEncodingRequiredStatus(t *testing.T) {
1684 server, ct, cancel := setUp(t, 0, encodingRequiredStatus)
1685 defer cancel()
1686 callHdr := &CallHdr{
1687 Host: "localhost",
1688 Method: "foo",
1689 }
1690 ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout)
1691 defer cancel()
1692 s, err := ct.NewStream(ctx, callHdr, nil)
1693 if err != nil {
1694 return
1695 }
1696 opts := WriteOptions{Last: true}
1697 if err := s.Write(nil, newBufferSlice(expectedRequest), &opts); err != nil && err != errStreamDone {
1698 t.Fatalf("Failed to write the request: %v", err)
1699 }
1700 p := make([]byte, http2MaxFrameLen)
1701 if _, err := s.readTo(p); err != io.EOF {
1702 t.Fatalf("Read got error %v, want %v", err, io.EOF)
1703 }
1704 if !testutils.StatusErrEqual(s.Status().Err(), encodingTestStatus.Err()) {
1705 t.Fatalf("stream with status %v, want %v", s.Status(), encodingTestStatus)
1706 }
1707 ct.Close(fmt.Errorf("closed manually by test"))
1708 server.stop()
1709 // Drain any remaining buffers from the stream since it was closed early.
1710 s.Read(math.MaxInt)
1711}
1712
1713func (s) TestInvalidContentType(t *testing.T) {
1714 server, ct, cancel := setUp(t, 0, invalidContentType)

Callers

nothing calls this directly

Calls 13

StatusErrEqualFunction · 0.92
setUpFunction · 0.85
newBufferSliceFunction · 0.85
readToMethod · 0.80
ErrMethod · 0.80
StatusMethod · 0.80
NewStreamMethod · 0.65
WriteMethod · 0.65
FatalfMethod · 0.65
CloseMethod · 0.65
ErrorfMethod · 0.65
stopMethod · 0.65

Tested by

no test coverage detected