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

Method TestDuplicateCompressorRegister

encoding/encoding_test.go:70–84  ·  view source on GitHub ↗

Tests the case where a compressor with the same name is registered multiple times. Test verifies the following: - the most recent registration is the one which is active - grpcutil.RegisteredCompressorNames contains a single instance of the previously registered compressor's name

(t *testing.T)

Source from the content-addressed store, hash-verified

68// - grpcutil.RegisteredCompressorNames contains a single instance of the
69// previously registered compressor's name
70func (s) TestDuplicateCompressorRegister(t *testing.T) {
71 encoding.RegisterCompressor(&mockNamedCompressor{})
72
73 // Register another instance of the same compressor.
74 mc := &mockNamedCompressor{}
75 encoding.RegisterCompressor(mc)
76 if got := encoding.GetCompressor("mock-compressor"); got != mc {
77 t.Fatalf("Unexpected compressor, got: %+v, want:%+v", got, mc)
78 }
79
80 wantNames := []string{"gzip", "mock-compressor"}
81 if !cmp.Equal(wantNames, grpcutil.RegisteredCompressorNames) {
82 t.Fatalf("Unexpected compressor names, got: %+v, want:%+v", grpcutil.RegisteredCompressorNames, wantNames)
83 }
84}
85
86// errProtoCodec wraps the proto codec and delegates to it if it is configured
87// to return a nil error. Else, it returns the configured error.

Callers

nothing calls this directly

Calls 4

RegisterCompressorFunction · 0.92
GetCompressorFunction · 0.92
FatalfMethod · 0.65
EqualMethod · 0.65

Tested by

no test coverage detected