equalLogEntry sorts the metadata entries by key (to compare metadata). This function is typically called with only two entries. It's written in this way so the code can be put in a for loop instead of copied twice.
(entries ...*binlogpb.GrpcLogEntry)
| 795 | // This function is typically called with only two entries. It's written in this |
| 796 | // way so the code can be put in a for loop instead of copied twice. |
| 797 | func equalLogEntry(entries ...*binlogpb.GrpcLogEntry) (equal bool) { |
| 798 | for i, e := range entries { |
| 799 | // Clear out some fields we don't compare. |
| 800 | e.Timestamp = nil |
| 801 | e.CallId = 0 // CallID is global to the binary, hard to compare. |
| 802 | if h := e.GetClientHeader(); h != nil { |
| 803 | h.Timeout = nil |
| 804 | tmp := append(h.Metadata.Entry[:0], h.Metadata.Entry...) |
| 805 | h.Metadata.Entry = tmp |
| 806 | sort.Slice(h.Metadata.Entry, func(i, j int) bool { return h.Metadata.Entry[i].Key < h.Metadata.Entry[j].Key }) |
| 807 | } |
| 808 | if h := e.GetServerHeader(); h != nil { |
| 809 | tmp := append(h.Metadata.Entry[:0], h.Metadata.Entry...) |
| 810 | h.Metadata.Entry = tmp |
| 811 | sort.Slice(h.Metadata.Entry, func(i, j int) bool { return h.Metadata.Entry[i].Key < h.Metadata.Entry[j].Key }) |
| 812 | } |
| 813 | if h := e.GetTrailer(); h != nil { |
| 814 | sort.Slice(h.Metadata.Entry, func(i, j int) bool { return h.Metadata.Entry[i].Key < h.Metadata.Entry[j].Key }) |
| 815 | } |
| 816 | |
| 817 | if i > 0 && !proto.Equal(e, entries[i-1]) { |
| 818 | return false |
| 819 | } |
| 820 | } |
| 821 | return true |
| 822 | } |
| 823 | |
| 824 | func testClientBinaryLog(t *testing.T, c *rpcConfig) error { |
| 825 | defer testSink.clear() |
no test coverage detected