Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ncode committed Oct 8, 2024
1 parent 7194534 commit b22e2bc
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions internal/ballot/ballot_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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)
}

Expand Down

0 comments on commit b22e2bc

Please sign in to comment.