mirror of
https://github.com/hanzoai/otel-collector.git
synced 2026-11-03 02:20:04 +00:00
Modules declare go 1.27.1 and the build images follow. go fix applied the modernizers; omitzero is not applied, since it changes what the JSON says. Co-authored-by: Hanzo Dev <[email protected]>
46 lines
1.2 KiB
Go
46 lines
1.2 KiB
Go
package fingerprint
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"go.opentelemetry.io/collector/pdata/pcommon"
|
|
)
|
|
|
|
func TestFingerprint(t *testing.T) {
|
|
attrs := pcommon.NewMap()
|
|
attrs.PutStr("key1", "value1")
|
|
attrs.PutStr("key2", "value2")
|
|
fp := NewFingerprint(ResourceFingerprintType, 0, attrs, nil)
|
|
if fp.Hash() != 4672270062576455370 {
|
|
t.Errorf("Fingerprint hash is incorrect: %d", fp.Hash())
|
|
}
|
|
}
|
|
|
|
func TestFingerprintWithExtras(t *testing.T) {
|
|
attrs := pcommon.NewMap()
|
|
attrs.PutStr("key1", "value1")
|
|
attrs.PutStr("key2", "value2")
|
|
fp := NewFingerprint(ResourceFingerprintType, 0, attrs, map[string]string{"key3": "value3"})
|
|
if fp.Hash() != 5425952980149109402 {
|
|
t.Errorf("Fingerprint hash is incorrect: %d", fp.Hash())
|
|
}
|
|
}
|
|
|
|
func TestFingerprintSameWithDifferentOrder(t *testing.T) {
|
|
for range 1000 {
|
|
attrs1 := pcommon.NewMap()
|
|
attrs1.PutStr("key1", "value1")
|
|
attrs1.PutStr("key2", "value2")
|
|
|
|
attrs2 := pcommon.NewMap()
|
|
attrs2.PutStr("key2", "value2")
|
|
attrs2.PutStr("key1", "value1")
|
|
|
|
fp1 := NewFingerprint(ResourceFingerprintType, 0, attrs1, nil)
|
|
fp2 := NewFingerprint(ResourceFingerprintType, 0, attrs2, nil)
|
|
if fp1.Hash() != fp2.Hash() {
|
|
t.Errorf("Fingerprint hash is incorrect: %d", fp1.Hash())
|
|
}
|
|
}
|
|
}
|