Skip to content

Commit

Permalink
fix: lint checkerr
Browse files Browse the repository at this point in the history
Signed-off-by: rfyiamcool <[email protected]>
  • Loading branch information
rfyiamcool committed Sep 25, 2023
1 parent c402a11 commit 406e3fa
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 13 deletions.
9 changes: 1 addition & 8 deletions .github/workflows/go_test.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
on:
push:
branches:
- main
pull_request:
branches:
- main

on: [push]
name: golangci-lint
jobs:
golangci:
Expand Down
6 changes: 3 additions & 3 deletions elector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func TestElectorSingleAcquire(t *testing.T) {
}()

time.Sleep(2 * time.Second)
assert.Equal(t, nil, el.IsLeader(nil))
assert.Equal(t, nil, el.IsLeader(context.Background()))
assert.Equal(t, el.GetLeaderID(), el.GetID())
_ = el.Stop()

Expand All @@ -128,7 +128,7 @@ func TestElectorSingleAcquire(t *testing.T) {
}

// after elector.stop, current instance is not leader
assert.Equal(t, ErrNonLeader, el.IsLeader(nil))
assert.Equal(t, ErrNonLeader, el.IsLeader(context.Background()))
}

func TestElectorMultipleAcquire(t *testing.T) {
Expand All @@ -151,7 +151,7 @@ func TestElectorMultipleAcquire(t *testing.T) {

var leaderCounter int
for _, el := range elections {
if el.IsLeader(nil) == nil {
if el.IsLeader(context.Background()) == nil {
leaderCounter++
}
}
Expand Down
4 changes: 2 additions & 2 deletions example/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ func main() {
s := gocron.NewScheduler(time.UTC)
s.WithDistributedElector(el)

s.Every("1s").Do(func() {
if el.IsLeader(context.TODO()) == nil {
_, _ = s.Every("1s").Do(func() {
if el.IsLeader(context.Background()) == nil {
fmt.Println("the current instance is leader")
} else {
fmt.Println("the current leader is", el.GetLeaderID())
Expand Down

0 comments on commit 406e3fa

Please sign in to comment.