Skip to content

Commit

Permalink
Fix linter complains
Browse files Browse the repository at this point in the history
  • Loading branch information
Mykyta committed Aug 25, 2024
1 parent 2c26467 commit 842ebfe
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions semaphore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,16 @@ func TestSemaphore(t *testing.T) {

// if number of locks are less than capacity, all should be acquired
if tt.lockTimes <= tt.capacity {
assert.Equal(t, int32(tt.lockTimes), atomic.LoadInt32(&locks))
assert.Equal(t, tt.lockTimes, int(atomic.LoadInt32(&locks)))
wg.Wait()
return
}
// if number of locks exceed capacity, it should hang after reaching the capacity
assert.Equal(t, int32(tt.capacity), atomic.LoadInt32(&locks))
assert.Equal(t, tt.capacity, int(atomic.LoadInt32(&locks)))
sema.Unlock()
time.Sleep(10 * time.Millisecond)
// after unlock, it should be able to acquire another lock
assert.Equal(t, int32(tt.capacity+1), atomic.LoadInt32(&locks))
assert.Equal(t, tt.capacity+1, int(atomic.LoadInt32(&locks)))
wg.Wait()
})
}
Expand Down Expand Up @@ -81,7 +81,7 @@ func TestSemaphore_TryLock(t *testing.T) {
}

// Check the acquired locks, it should not exceed capacity.
assert.Equal(t, int32(tt.expectedLocks), atomic.LoadInt32(&locks))
assert.Equal(t, tt.expectedLocks, int(atomic.LoadInt32(&locks)))
})
}
}
10 changes: 5 additions & 5 deletions sizedgroup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func TestSizedGroup(t *testing.T) {
var c uint32

for i := 0; i < 1000; i++ {
swg.Go(func(ctx context.Context) {
swg.Go(func(context.Context) {
time.Sleep(5 * time.Millisecond)
atomic.AddUint32(&c, 1)
})
Expand All @@ -32,7 +32,7 @@ func TestSizedGroup_Discard(t *testing.T) {
var c uint32

for i := 0; i < 100; i++ {
swg.Go(func(ctx context.Context) {
swg.Go(func(context.Context) {
time.Sleep(5 * time.Millisecond)
atomic.AddUint32(&c, 1)
})
Expand All @@ -47,7 +47,7 @@ func TestSizedGroup_DiscardAfterTreshold(t *testing.T) {
var c uint32

for i := 0; i < 100; i++ {
swg.Go(func(ctx context.Context) {
swg.Go(func(context.Context) {
time.Sleep(5 * time.Millisecond)
atomic.AddUint32(&c, 1)
})
Expand Down Expand Up @@ -79,7 +79,7 @@ func TestSizedGroup_Canceled(t *testing.T) {
var c uint32

for i := 0; i < 100; i++ {
swg.Go(func(ctx context.Context) {
swg.Go(func(context.Context) {
select {
case <-ctx.Done():
return
Expand All @@ -99,7 +99,7 @@ func ExampleSizedGroup_go() {

var c uint32
for i := 0; i < 1000; i++ {
grp.Go(func(ctx context.Context) { // Go call is non-blocking, like regular go statement
grp.Go(func(context.Context) { // Go call is non-blocking, like regular go statement
// do some work in 10 goroutines in parallel
atomic.AddUint32(&c, 1)
time.Sleep(10 * time.Millisecond)
Expand Down

0 comments on commit 842ebfe

Please sign in to comment.