コード例 #1
0
func (suite *SimpleDetectorSuite) TestDetectDelegatesToStrategy() {
	strategy := &TestStrategy{}
	strategy.On("Expired", "foo", suite.Pool).Return([]string{}, nil)

	d := heartbeat.NewDetector("foo", suite.Pool, strategy)
	d.Detect()

	strategy.AssertCalled(suite.T(), "Expired", "foo", suite.Pool)
}
コード例 #2
0
func (suite *SimpleDetectorSuite) TestDetectPropogatesValues() {
	strategy := &TestStrategy{}
	strategy.On("Expired", "foo", suite.Pool).Return([]string{"foo", "bar"}, errors.New("baz"))

	d := heartbeat.NewDetector("foo", suite.Pool, strategy)
	expired, err := d.Detect()

	suite.Assert().Equal(expired, []string{"foo", "bar"})
	suite.Assert().Equal(err.Error(), "baz")
}
コード例 #3
0
func (suite *SimpleDetectorSuite) TestConstruction() {
	d := heartbeat.NewDetector("foo", suite.Pool, heartbeat.HashExpireyStrategy{time.Second})

	suite.Assert().IsType(heartbeat.SimpleDetector{}, d)
}