sharding_test.go 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. package sharding
  2. import (
  3. "testing"
  4. "github.com/stretchr/testify/assert"
  5. )
  6. func TestSiphash64(t *testing.T) {
  7. users := [][]string{
  8. {
  9. "5a4b7347200a6e0c185d6101",
  10. "5b74c444acdd315c509b78fe",
  11. "5c03e009a496130c2d9bc970",
  12. "5c6ab5a74867f267d560dd9f",
  13. "5b80a2b28be129507d176284",
  14. "5a4b7347200a6e0c185d6101",
  15. "5b74c444acdd315c509b78fe",
  16. "5c03e009a496130c2d9bc970",
  17. "5c6ab5a74867f267d560dd9f",
  18. "5b80a2b28be129507d176284",
  19. "5b8d157aacdd313508a892f2",
  20. "5bf942b4a496130c2d9b7378",
  21. "5c7fc28cd065f17f9edd3698",
  22. "5bf40bd22c64fc5ea63a5174",
  23. },
  24. {
  25. "5b839929acdd31271f03ded5",
  26. "5bc9e28e2c64fc1a69a28e36",
  27. "5b935d96a49613677b90b589",
  28. "5b97acb2a49613677b910f47",
  29. "5c902f3aff5be73689b4b522",
  30. },
  31. {
  32. "5cdbee881a722f0001b9ce99",
  33. "",
  34. "5caca58f53add40001c20aaa",
  35. "5beee68520c25041544e353a",
  36. "5b0b957d0179b05769cbecde",
  37. "5bbf45940ab7b7589aa1025f",
  38. "5ac63009200a6e79cadf5175",
  39. "5c94ed250ab7b7386c294662",
  40. "5b9f8ccb2c64fc5832e47d3f",
  41. },
  42. }
  43. for shard, ids := range users {
  44. for _, id := range ids {
  45. assert.Equal(t, uint64(shard), sharding(id))
  46. }
  47. }
  48. }