Exemplo n.º 1
0
func (suite *HeartbeaterSuite) TestConstruction() {
	h := heartbeat.New("foo", "bar", time.Second, suite.Pool)

	suite.Assert().Equal(h.ID, "foo")
	suite.Assert().Equal(h.Location, "bar")
	suite.Assert().Equal(h.Interval(), time.Second)
}
Exemplo n.º 2
0
func (suite *HeartbeaterSuite) TestSetStrategy() {
	h := heartbeat.New("foo", "bar", 10*time.Second, suite.Pool)
	strategy := &StrategyStub{}

	h.SetStrategy(strategy)

	suite.Assert().Equal(h.Strategy, strategy)
}
Exemplo n.º 3
0
func (suite *HeartbeaterSuite) TestHeartCreation() {
	h := heartbeat.New("foo", "bar", 10*time.Second, suite.Pool)

	heart, ok := h.Heart().(heartbeat.SimpleHeart)

	suite.Assert().True(ok, "heart: expected heart to be heartbeat.SimpleHeart")
	suite.Assert().Equal(heart.ID, "foo")
	suite.Assert().Equal(heart.Location, "bar")
	suite.Assert().Equal(heart.Interval, 10*time.Second)
}
Exemplo n.º 4
0
func (suite *HeartbeaterSuite) TestDetectorCreation() {
	h := heartbeat.New("foo", "bar", 10*time.Second, suite.Pool)
	strategy := &StrategyStub{}
	h.SetStrategy(strategy)

	detector, ok := h.Detector().(heartbeat.SimpleDetector)

	suite.Assert().True(ok, "detector: expected detector to be heartbeat.SimpleDetector")
	suite.Assert().Equal(detector.Location(), "bar")
	suite.Assert().Equal(detector.Strategy(), strategy)
}
Exemplo n.º 5
0
func (suite *HeartbeaterSuite) TestMaxAgeScalesLargeValues() {
	h := heartbeat.New("foo", "bar", 10*time.Second, suite.Pool)

	suite.Assert().Equal(h.MaxAge(), 15*time.Second)
}
Exemplo n.º 6
0
func (suite *HeartbeaterSuite) TestMaxAgePadsSmallValues() {
	h := heartbeat.New("foo", "bar", 3*time.Second, suite.Pool)

	suite.Assert().Equal(h.MaxAge(), 4*time.Second)
}