From f0b8ad1e3e8113de4b14dcc93bc72ed4e4bd33cb Mon Sep 17 00:00:00 2001 From: Hugo Wetterberg Date: Mon, 19 Feb 2024 08:37:02 +0100 Subject: [PATCH] fix test and linting errors --- client_test.go | 6 +++--- joe_test.go | 4 ++-- replay_provider.go | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/client_test.go b/client_test.go index 5bd9cdf..235961c 100644 --- a/client_test.go +++ b/client_test.go @@ -181,7 +181,7 @@ func TestConnection_Connect_resetBody(t *testing.T) { }, } - ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { + ts := httptest.NewServer(http.HandlerFunc(func(_ http.ResponseWriter, _ *http.Request) { time.Sleep(time.Millisecond * 5) })) defer ts.Close() @@ -250,7 +250,7 @@ func TestConnection_Connect_validator(t *testing.T) { }, } - ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {})) + ts := httptest.NewServer(http.HandlerFunc(func(_ http.ResponseWriter, _ *http.Request) {})) defer ts.Close() c := &sse.Client{ @@ -611,7 +611,7 @@ func TestConnection_reconnect(t *testing.T) { retries := 0 c := sse.Client{ HTTPClient: ts.Client(), - OnRetry: func(err error, d time.Duration) { + OnRetry: func(_ error, _ time.Duration) { retries++ if retries == 3 { cancel() diff --git a/joe_test.go b/joe_test.go index fe0f25b..bcca1fb 100644 --- a/joe_test.go +++ b/joe_test.go @@ -229,7 +229,7 @@ data: world func TestJoe_errors(t *testing.T) { t.Parallel() - fin, err := sse.NewFiniteReplayProvider(1, false) + fin, err := sse.NewFiniteReplayProvider(2, false) tests.Equal(t, err, nil, "should create new FiniteReplayProvider") j := &sse.Joe{ @@ -277,7 +277,7 @@ func TestJoe_errors(t *testing.T) { err = j.Subscribe(ctx, sse.Subscription{Client: client, Topics: []string{sse.DefaultTopic}}) tests.Equal(t, err, callErr, "error not received from send") - tests.Equal(t, called, 1, "callback was called after subscribe returned") + tests.Equal(t, called, 0, "callback was called after subscribe returned") <-done } diff --git a/replay_provider.go b/replay_provider.go index e5ceede..81b9356 100644 --- a/replay_provider.go +++ b/replay_provider.go @@ -31,8 +31,8 @@ func NewFiniteReplayProvider( // FiniteReplayProvider is a replay provider that replays at maximum a certain number of events. // The events must have an ID unless the AutoIDs flag is toggled. type FiniteReplayProvider struct { - cap int buf []messageWithTopics + cap int head int tail int autoIDs bool