Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update: session counter test to use new atomic counter #2

Merged
merged 1 commit into from
Sep 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions cuid2.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,13 +151,6 @@ func WithFingerprint(fingerprint string) Option {
}
}

func createCounter(initialCount int64) func() int64 {
return func() int64 {
initialCount++
return initialCount - 1
}
}

func createFingerprint(randomFunc func() float64, envKeyString string) string {
sourceString := createEntropy(MaxIdLength, randomFunc)

Expand Down
12 changes: 6 additions & 6 deletions cuid2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,13 @@ func TestGeneratingCuidWithMaxLength(t *testing.T) {
// Internal Tests
func TestSessionCounter(t *testing.T) {
var initialSessionCount int64 = 10
sessionCounter := createCounter(initialSessionCount)
expectedCounts := []int64{10, 11, 12, 13}
sessionCounter := NewSessionCounter(initialSessionCount)
expectedCounts := []int64{11, 12, 13, 14}
actualCounts := []int64{
sessionCounter(),
sessionCounter(),
sessionCounter(),
sessionCounter(),
sessionCounter.Increment(),
sessionCounter.Increment(),
sessionCounter.Increment(),
sessionCounter.Increment(),
}

for index, actualCount := range actualCounts {
Expand Down