aboutsummaryrefslogtreecommitdiff
path: root/weed/sequence/snowflake_sequencer_test.go
blob: 731e330c54abc3703d0acb9a368e0d1e2eac0d48 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
package sequence

import (
	"encoding/hex"
	"github.com/chrislusf/seaweedfs/weed/storage/types"
	"github.com/stretchr/testify/assert"
	"testing"
)

func TestSequencer(t *testing.T) {
	seq, err := NewSnowflakeSequencer("for_test", 1)
	assert.Equal(t, nil, err)
	last := uint64(0)
	bytes := make([]byte, types.NeedleIdSize)
	for i := 0; i < 100; i++ {
		next := seq.NextFileId(1)
		types.NeedleIdToBytes(bytes, types.NeedleId(next))
		println(hex.EncodeToString(bytes))
		if last == next {
			t.Errorf("last %d next %d", last, next)
		}
		last = next
	}

}