Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added unit test for vitess/go/vt/vttablet/tabletserver/heartbeat #15100

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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")
}
}


Loading