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)
| 68 | // - grpcutil.RegisteredCompressorNames contains a single instance of the |
| 69 | // previously registered compressor's name |
| 70 | func (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. |
nothing calls this directly
no test coverage detected