diff --git a/api/controller/triggers.go b/api/controller/triggers.go index 4c6ec7075..de97e8d3e 100644 --- a/api/controller/triggers.go +++ b/api/controller/triggers.go @@ -35,7 +35,7 @@ func CreateTrigger(dataBase moira.Database, trigger *dto.TriggerModel, timeSerie return nil, api.ErrorInternalServer(err) } if exists { - return nil, api.ErrorInvalidRequest(fmt.Errorf("trigger with this ID already exists")) + return nil, api.ErrorInvalidRequest(fmt.Errorf("trigger with this ID (%s) already exists", trigger.ID)) } } resp, err := saveTrigger(dataBase, trigger.ToMoiraTrigger(), trigger.ID, timeSeriesNames) diff --git a/api/controller/triggers_test.go b/api/controller/triggers_test.go index 30b174d54..a70ca9d35 100644 --- a/api/controller/triggers_test.go +++ b/api/controller/triggers_test.go @@ -73,11 +73,12 @@ func TestCreateTrigger(t *testing.T) { }) Convey("Trigger already exists", t, func() { - triggerModel := dto.TriggerModel{ID: uuid.Must(uuid.NewV4()).String()} + triggerId := uuid.Must(uuid.NewV4()).String() + triggerModel := dto.TriggerModel{ID: triggerId} trigger := triggerModel.ToMoiraTrigger() dataBase.EXPECT().GetTrigger(triggerModel.ID).Return(*trigger, nil) resp, err := CreateTrigger(dataBase, &triggerModel, make(map[string]bool)) - So(err, ShouldResemble, api.ErrorInvalidRequest(fmt.Errorf("trigger with this ID already exists"))) + So(err, ShouldResemble, api.ErrorInvalidRequest(fmt.Errorf("trigger with this ID (%s) already exists", triggerId))) So(resp, ShouldBeNil) })