From b22e2bc49bf15c38f229c29a3d4aec2afd90ee1b Mon Sep 17 00:00:00 2001 From: Juliano Martinez Date: Tue, 8 Oct 2024 21:33:31 +0200 Subject: [PATCH] update tests --- internal/ballot/ballot_test.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/internal/ballot/ballot_test.go b/internal/ballot/ballot_test.go index 63dca32..7eddf08 100644 --- a/internal/ballot/ballot_test.go +++ b/internal/ballot/ballot_test.go @@ -1432,17 +1432,19 @@ func TestSessionWrapper_RenewPeriodic(t *testing.T) { sessionID := "session_id" writeOptions := &api.WriteOptions{} doneCh := make(chan struct{}) + // Convert to receive-only channel + var receiveOnlyDoneCh <-chan struct{} = doneCh expectedErr := errors.New("renew error") - mockSession.On("RenewPeriodic", initialTTL, sessionID, writeOptions, doneCh).Return(expectedErr) + mockSession.On("RenewPeriodic", initialTTL, sessionID, writeOptions, receiveOnlyDoneCh).Return(expectedErr) // Act - err := sessionWrapper.RenewPeriodic(initialTTL, sessionID, writeOptions, doneCh) + err := sessionWrapper.RenewPeriodic(initialTTL, sessionID, writeOptions, receiveOnlyDoneCh) // Assert assert.Equal(t, expectedErr, err) - mockSession.AssertCalled(t, "RenewPeriodic", initialTTL, sessionID, writeOptions, doneCh) + mockSession.AssertCalled(t, "RenewPeriodic", initialTTL, sessionID, writeOptions, receiveOnlyDoneCh) } func TestKVWrapper_Get(t *testing.T) { @@ -1616,8 +1618,8 @@ func (m *MockSession) Info(sessionID string, q *api.QueryOptions) (*api.SessionE return args.Get(0).(*api.SessionEntry), args.Get(1).(*api.QueryMeta), args.Error(2) } -func (m *MockSession) RenewPeriodic(initialTTL string, sessionID string, q *api.WriteOptions, doneCh <-chan struct{}) error { - args := m.Called(initialTTL, sessionID, q, doneCh) +func (m *MockSession) RenewPeriodic(initialTTL string, id string, q *api.WriteOptions, doneCh <-chan struct{}) error { + args := m.Called(initialTTL, id, q, doneCh) return args.Error(0) }