You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
555 B

  1. package sequence
  2. import (
  3. "encoding/hex"
  4. "github.com/chrislusf/seaweedfs/weed/storage/types"
  5. "github.com/stretchr/testify/assert"
  6. "testing"
  7. )
  8. func TestSequencer(t *testing.T) {
  9. seq, err := NewSnowflakeSequencer("for_test", 1)
  10. assert.Equal(t, nil, err)
  11. last := uint64(0)
  12. bytes := make([]byte, types.NeedleIdSize)
  13. for i := 0; i < 100; i++ {
  14. next := seq.NextFileId(1)
  15. types.NeedleIdToBytes(bytes, types.NeedleId(next))
  16. println(hex.EncodeToString(bytes))
  17. if last == next {
  18. t.Errorf("last %d next %d", last, next)
  19. }
  20. last = next
  21. }
  22. }