Skip to content

Commit

Permalink
fix(sharding): added unit tests for ID
Browse files Browse the repository at this point in the history
  • Loading branch information
cnlangzi committed Feb 24, 2024
1 parent 160dd57 commit d331ffd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions sharding/id_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ func TestID(t *testing.T) {
{
name: "build_max_values_should_work",
timeNow: time.UnixMilli(TimeEnd),
workerID: 3,
databaseID: 1023,
workerID: MaxWorkerID,
databaseID: MaxDatabaseID,
tableRotate: Daily,
sequence: 1023,
sequence: MaxSequence,
},
{
name: "build_should_work",
Expand Down
4 changes: 2 additions & 2 deletions sharding/option.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ type Option func(g *Generator)

func WithWorker(i int8) Option {
return func(g *Generator) {
if i > 0 && i < 4 {
if i >= 0 && i <= MaxWorkerID {
g.workerID = i
}
}
}

func WithDatabase(num int16) Option {
return func(g *Generator) {
if num > 0 && num < 1024 {
if num >= 0 && num <= MaxDatabaseID {
g.databaseNum = num
}
}
Expand Down

0 comments on commit d331ffd

Please sign in to comment.