Skip to content

Commit

Permalink
added unit test for vitess/go/vt/vttablet/tabletserver/heartbeat
Browse files Browse the repository at this point in the history
Signed-off-by: Kinshuk Dwivedi <[email protected]>
  • Loading branch information
Kinshuk0 committed Jan 31, 2024
1 parent 3147240 commit ca4df0a
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions go/vt/vttablet/tabletserver/heartbeat/heartbeat_writer_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package heartbeat

import (
"testing"
)

// MockHeartbeatWriter is a mock implementation of the HeartbeatWriter interface for testing purposes.
type MockHeartbeatWriter struct {
RequestedHeartbeats bool
}

// RequestHeartbeats implements the RequestHeartbeats method of the HeartbeatWriter interface.
func (m *MockHeartbeatWriter) RequestHeartbeats() {
m.RequestedHeartbeats = true
}

func TestHeartbeatWriter_RequestHeartbeats(t *testing.T) {
// Create an instance of the MockHeartbeatWriter
mockWriter := &MockHeartbeatWriter{}

// Call the RequestHeartbeats method
mockWriter.RequestHeartbeats()

// Verify that the RequestedHeartbeats flag is set to true
if !mockWriter.RequestedHeartbeats {
t.Error("Expected RequestedHeartbeats to be true, got false")
}
}


0 comments on commit ca4df0a

Please sign in to comment.