MCPcopy
hub / github.com/gotify/server / Test_UpdateConfig_ioError_expect500

Method Test_UpdateConfig_ioError_expect500

api/plugin_test.go:566–594  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

564}
565
566func (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
596func (s *PluginSuite) Test_UpdateConfig_notImplemented_expect400() {
597 conf, err := s.db.GetPluginConfByUserAndPath(1, mock.ModulePath)

Callers

nothing calls this directly

Calls 6

WithUserFunction · 0.92
UnreadableReaderFunction · 0.92
InstanceMethod · 0.80
UpdateConfigMethod · 0.80
GetPluginConfByIDMethod · 0.65

Tested by

no test coverage detected