Skip to content

Commit 1486002

Browse files
committed
Fix general warnings golang warnings.
1 parent 2939032 commit 1486002

File tree

5 files changed

+23
-22
lines changed

5 files changed

+23
-22
lines changed

api_retries_test.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@ import (
44
"context"
55
"encoding/json"
66
"errors"
7-
"github.com/stretchr/testify/assert"
87
"log"
98
"net/http/httptest"
109
"os"
1110
"testing"
11+
12+
"github.com/stretchr/testify/assert"
1213
)
1314

1415
func TestRetries_Empty(t *testing.T) {
@@ -33,8 +34,6 @@ func TestRetries_NotEmpty(t *testing.T) {
3334

3435
assert.Equal(t, "[]\n", recorder.Body.String())
3536

36-
ctx := context.Background()
37-
3837
// test API replies with registered workers
3938
opts, err := SetupDefaultTestOptionsWithNamespace("prod")
4039
assert.NoError(t, err)
@@ -71,14 +70,13 @@ func TestRetries_NotEmpty(t *testing.T) {
7170
},
7271
}
7372

74-
ctx = context.Background()
7573
var messages []string
7674
for index, test := range tests {
7775
// Test panic
7876
wares.build("myqueue", mgr, test.f)(message)
7977

8078
// retries order is not guaranteed
81-
retries, err := opts.client.ZRange(ctx, retryQueue(opts.Namespace), 0, -1).Result()
79+
retries, err := opts.client.ZRange(context.Background(), retryQueue(opts.Namespace), 0, -1).Result()
8280
assert.NoError(t, err)
8381
assert.Len(t, retries, index+1)
8482
messages = append(messages, message.ToJson())

heartbeat_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@ package workers
22

33
import (
44
"encoding/json"
5-
"github.com/stretchr/testify/assert"
65
"log"
76
"os"
87
"testing"
98
"time"
9+
10+
"github.com/stretchr/testify/assert"
1011
)
1112

1213
func TestBuildHeartbeat(t *testing.T) {
@@ -52,6 +53,7 @@ func TestBuildHeartbeatWorkerMessage(t *testing.T) {
5253
return nil
5354
})
5455
msg, err := NewMsg("{\"class\":\"MyWorker\",\"jid\":\"jid-123\"}")
56+
assert.NoError(t, err)
5557

5658
testLogger := log.New(os.Stdout, "test-go-workers2: ", log.Ldate|log.Lmicroseconds)
5759

options.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ func processOptionsWithRedisClient(options Options, client *redis.Client) (Optio
131131
}
132132

133133
if client == nil {
134-
return Options{}, errors.New("Redis client is nil; Redis client is not configured")
134+
return Options{}, errors.New("redis client is nil; Redis client is not configured")
135135
}
136136

137137
options.client = client
@@ -148,7 +148,7 @@ func processOptionsWithRedisClient(options Options, client *redis.Client) (Optio
148148

149149
func validateGeneralOptions(options Options) (Options, error) {
150150
if options.ProcessID == "" {
151-
return Options{}, errors.New("Options requires a ProcessID, which uniquely identifies this instance")
151+
return Options{}, errors.New("options requires a ProcessID, which uniquely identifies this instance")
152152
}
153153

154154
if options.Namespace != "" {

producer_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ func TestProducer_EnqueueIn(t *testing.T) {
118118

119119
var data EnqueueData
120120
elem, err := rc.ZRange(ctx, scheduleQueue, 0, -1).Result()
121+
assert.NoError(t, err)
121122
bytes := elem[0]
122123
err = json.Unmarshal([]byte(bytes), &data)
123124
assert.NoError(t, err)

worker_test.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,21 @@ type dummyFetcher struct {
2323
closed func() bool
2424
}
2525

26-
func (d dummyFetcher) Queue() string { return d.queue() }
27-
func (d dummyFetcher) InProgressQueue() string { return d.inProgressQueue() }
28-
func (d dummyFetcher) Fetch() { d.fetch() }
29-
func (d dummyFetcher) Acknowledge(m *Msg) { d.acknowledge(m) }
30-
func (d dummyFetcher) Ready() chan bool { return d.ready() }
31-
func (d dummyFetcher) Messages() chan *Msg { return d.messages() }
32-
func (d dummyFetcher) Close() { d.close() }
33-
func (d dummyFetcher) Closed() bool { return d.closed() }
34-
35-
func (d dummyFetcher) SetActive(active bool) {
26+
func (d *dummyFetcher) Queue() string { return d.queue() }
27+
func (d *dummyFetcher) InProgressQueue() string { return d.inProgressQueue() }
28+
func (d *dummyFetcher) Fetch() { d.fetch() }
29+
func (d *dummyFetcher) Acknowledge(m *Msg) { d.acknowledge(m) }
30+
func (d *dummyFetcher) Ready() chan bool { return d.ready() }
31+
func (d *dummyFetcher) Messages() chan *Msg { return d.messages() }
32+
func (d *dummyFetcher) Close() { d.close() }
33+
func (d *dummyFetcher) Closed() bool { return d.closed() }
34+
35+
func (d *dummyFetcher) SetActive(active bool) {
3636
d.lock.Lock()
3737
defer d.lock.Unlock()
3838
d.isActive = active
3939
}
40-
func (d dummyFetcher) IsActive() bool {
40+
func (d *dummyFetcher) IsActive() bool {
4141
d.lock.Lock()
4242
defer d.lock.Unlock()
4343
return d.isActive
@@ -99,7 +99,7 @@ func TestWorker(t *testing.T) {
9999
var wg sync.WaitGroup
100100
go func() {
101101
wg.Add(1)
102-
w.start(df)
102+
w.start(&df)
103103
wg.Done()
104104
}()
105105

@@ -120,7 +120,7 @@ func TestWorker(t *testing.T) {
120120
assert.Equal(t, w.inProgressQueue, df.InProgressQueue())
121121

122122
t.Run("cannot start while running", func(t *testing.T) {
123-
w.start(df)
123+
w.start(&df)
124124
// This test would time out if w.start doesn't return immediately
125125
})
126126

@@ -192,7 +192,7 @@ func TestWorkerProcessesAndAcksMessages(t *testing.T) {
192192

193193
go func() {
194194
wg.Add(1)
195-
w.start(df)
195+
w.start(&df)
196196
wg.Done()
197197
}()
198198

0 commit comments

Comments
 (0)