()
| 564 | } |
| 565 | |
| 566 | func (s *PluginSuite) Test_UpdateConfig_ioError_expect500() { |
| 567 | conf, err := s.db.GetPluginConfByUserAndPath(1, mock.ModulePath) |
| 568 | assert.NoError(s.T(), err) |
| 569 | inst, err := s.manager.Instance(conf.ID) |
| 570 | assert.Nil(s.T(), err) |
| 571 | mockInst := inst.(*mock.PluginInstance) |
| 572 | origConfig := mockInst.Config |
| 573 | |
| 574 | { |
| 575 | test.WithUser(s.ctx, 1) |
| 576 | |
| 577 | s.ctx.Request = httptest.NewRequest("POST", fmt.Sprintf("/plugin/%d/config", conf.ID), test.UnreadableReader()) |
| 578 | s.ctx.Header("Content-Type", "application/x-yaml") |
| 579 | s.ctx.Params = gin.Params{{Key: "id", Value: fmt.Sprint(conf.ID)}} |
| 580 | s.a.UpdateConfig(s.ctx) |
| 581 | |
| 582 | assert.Equal(s.T(), 500, s.recorder.Code) |
| 583 | assert.Equal(s.T(), origConfig, mockInst.Config, "config should not be received by plugin") |
| 584 | |
| 585 | var pluginFromDBBytes []byte |
| 586 | if pluginConf, err := s.db.GetPluginConfByID(conf.ID); assert.NoError(s.T(), err) { |
| 587 | pluginFromDBBytes = pluginConf.Config |
| 588 | } |
| 589 | pluginFromDB := new(mock.PluginConfig) |
| 590 | err := yaml.Unmarshal(pluginFromDBBytes, pluginFromDB) |
| 591 | assert.Nil(s.T(), err) |
| 592 | assert.Equal(s.T(), origConfig, pluginFromDB, "config should not be updated in database") |
| 593 | } |
| 594 | } |
| 595 | |
| 596 | func (s *PluginSuite) Test_UpdateConfig_notImplemented_expect400() { |
| 597 | conf, err := s.db.GetPluginConfByUserAndPath(1, mock.ModulePath) |
nothing calls this directly
no test coverage detected