Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions apps/server/src/modules/monitor/monitor.service.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,9 @@ func (mr *MonitorServiceImpl) UpdatePartial(ctx context.Context, id string, moni
ResendInterval: monitor.ResendInterval,
Active: monitor.Active,
Status: monitor.Status,
Config: monitor.Config,
ProxyId: monitor.ProxyId,
PushToken: monitor.PushToken,
}

err := mr.monitorRepository.UpdatePartial(ctx, id, model)
Expand Down
29 changes: 29 additions & 0 deletions apps/server/src/modules/monitor/monitor.service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,35 @@ func TestMonitorService_UpdatePartial(t *testing.T) {
// EventBus should not be called when noPublish is true
})

t.Run("successful partial update with config field", func(t *testing.T) {
service, mockRepo, _, _, _, _, _, _ := setupMonitorService()
monitorID := "monitor123"
config := "{\"host\":\"example.com\",\"port\":8080}"
updateDto := &PartialUpdateDto{
Config: &config,
}

expectedModel := &Model{
ID: monitorID,
Name: "Test Monitor",
Config: config,
}

mockRepo.On("UpdatePartial", ctx, monitorID, mock.MatchedBy(func(m *UpdateModel) bool {
return *m.ID == monitorID &&
m.Config != nil &&
*m.Config == config
})).Return(nil)

mockRepo.On("FindByID", ctx, monitorID).Return(expectedModel, nil)

result, err := service.UpdatePartial(ctx, monitorID, updateDto, false)

assert.NoError(t, err)
assert.Equal(t, expectedModel, result)
mockRepo.AssertExpectations(t)
})

t.Run("update error", func(t *testing.T) {
service, mockRepo, _, _, _, _, _, _ := setupMonitorService()
monitorID := "monitor123"
Expand Down
Loading