-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added unit test for vitess/go/vt/vttablet/tabletserver/heartbeat
Signed-off-by: Kinshuk Dwivedi <[email protected]>
- Loading branch information
Showing
1 changed file
with
30 additions
and
0 deletions.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
go/vt/vttablet/tabletserver/heartbeat/heartbeat_writer_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") | ||
} | ||
} | ||
|
||
|