(t *testing.T)
| 160 | } |
| 161 | |
| 162 | func TestSpanIDAndKindToToken(t *testing.T) { |
| 163 | tc := []struct { |
| 164 | spanID []byte |
| 165 | expected uint64 |
| 166 | }{ |
| 167 | { |
| 168 | spanID: []byte{0x60, 0xd8, 0xa9, 0xbd}, |
| 169 | }, |
| 170 | { |
| 171 | spanID: []byte{0x8e, 0xf6, 0x37, 0x90, 0x22, 0x57, 0xb7, 0x43}, |
| 172 | }, |
| 173 | { |
| 174 | spanID: []byte{0x18, 0xcc, 0xd9, 0x6d, 0x70, 0xc1, 0xbd, 0xf9}, |
| 175 | }, |
| 176 | { |
| 177 | spanID: []byte{0x8e, 0xf6, 0x37, 0x90, 0x22, 0x57, 0xb7, 0x43, 0xff}, |
| 178 | }, |
| 179 | } |
| 180 | |
| 181 | for _, tt := range tc { |
| 182 | tokenIDOnly := SpanIDToUint64(tt.spanID) |
| 183 | tokensForKind := map[uint64]struct{}{} |
| 184 | |
| 185 | for kind := 0; kind < 8; kind++ { |
| 186 | token := SpanIDAndKindToToken(tt.spanID, kind) |
| 187 | |
| 188 | _, exists := tokensForKind[token] |
| 189 | assert.False(t, exists, "token expected to be unique for different span kind") |
| 190 | assert.NotEqual(t, tokenIDOnly, token) |
| 191 | tokensForKind[token] = struct{}{} |
| 192 | } |
| 193 | } |
| 194 | |
| 195 | t.Run("when kind is outside the boundaries", func(t *testing.T) { |
| 196 | spanID := []byte{0x60} |
| 197 | t1 := SpanIDAndKindToToken(spanID, 1000) |
| 198 | t2 := SpanIDAndKindToToken(spanID, -2) |
| 199 | |
| 200 | assert.Equal(t, t1, t2) |
| 201 | }) |
| 202 | } |
| 203 | |
| 204 | func TestTokenForID(t *testing.T) { |
| 205 | h := NewTokenHasher() |
nothing calls this directly
no test coverage detected