@@ -128,6 +128,33 @@ func (s *CompositeFeatureServiceTestSuite) TestGetDecisionReturnsError() {
128128 s .mockFeatureService2 .AssertExpectations (s .T ())
129129}
130130
131+ func (s * CompositeFeatureServiceTestSuite ) TestGetDecisionReturnsLastDecisionWithError () {
132+ // test that GetDecision returns the last decision with error if all decision services return error
133+ testUserContext := entities.UserContext {
134+ ID : "test_user_1" ,
135+ }
136+
137+ expectedDecision := FeatureDecision {
138+ Variation : & testExp1113Var2223 ,
139+ }
140+ s .mockFeatureService .On ("GetDecision" , s .testFeatureDecisionContext , testUserContext ).Return (expectedDecision , errors .New ("Error making decision" ))
141+
142+ s .mockFeatureService2 .On ("GetDecision" , s .testFeatureDecisionContext , testUserContext ).Return (expectedDecision , errors .New ("test error" ))
143+
144+ compositeFeatureService := & CompositeFeatureService {
145+ featureServices : []FeatureService {
146+ s .mockFeatureService ,
147+ s .mockFeatureService2 ,
148+ },
149+ }
150+ decision , err := compositeFeatureService .GetDecision (s .testFeatureDecisionContext , testUserContext )
151+ s .Equal (expectedDecision , decision )
152+ s .Error (err )
153+ s .Equal (err .Error (), "test error" )
154+ s .mockFeatureService .AssertExpectations (s .T ())
155+ s .mockFeatureService2 .AssertExpectations (s .T ())
156+ }
157+
131158func (s * CompositeFeatureServiceTestSuite ) TestNewCompositeFeatureService () {
132159 // Assert that the service is instantiated with the correct child services in the right order
133160 compositeExperimentService := NewCompositeExperimentService ()
0 commit comments