+func TestSubscribeChannelDBFailure(t *testing.T) {
+ mockedErr := errors.New("Some DB Backend Subscribe Error")
+ ps, r, db := setupHaEnv(true)
+ ch := make(chan *redis.Message)
+ ps.On("Channel").Return(ch)
+ ps.On("Subscribe").Return(mockedErr)
+ err := db.SubscribeChannelDB(func(channel string, payload ...string) {
+ }, "{prefix},channel")
+ assert.NotNil(t, err)
+ assert.Contains(t, err.Error(), mockedErr.Error())
+ r.AssertExpectations(t)
+ ps.AssertExpectations(t)
+}
+
+func TestUnsubscribeChannelDBFailure(t *testing.T) {
+ mockedErr := errors.New("Some DB Backend Unsubscribe Error")
+ ps, r, db := setupHaEnv(true)
+ ch := make(chan *redis.Message)
+ ps.On("Channel").Return(ch)
+ ps.On("Subscribe").Return(nil)
+ ps.On("Unsubscribe").Return(mockedErr)
+ err := db.SubscribeChannelDB(func(channel string, payload ...string) {
+ }, "{prefix},channel")
+ assert.Nil(t, err)
+ err = db.UnsubscribeChannelDB("{prefix},channel")
+ assert.NotNil(t, err)
+ assert.Contains(t, err.Error(), mockedErr.Error())
+ r.AssertExpectations(t)
+ ps.AssertExpectations(t)
+}
+