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

Method Test_GetConfig

api/plugin_test.go:378–398  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

376}
377
378func (s *PluginSuite) Test_GetConfig() {
379 conf, err := s.db.GetPluginConfByUserAndPath(1, mock.ModulePath)
380 assert.NoError(s.T(), err)
381 inst, err := s.manager.Instance(conf.ID)
382 assert.Nil(s.T(), err)
383 mockInst := inst.(*mock.PluginInstance)
384
385 assert.Equal(s.T(), mockInst.DefaultConfig(), mockInst.Config, "Initial config should be default config")
386 {
387 test.WithUser(s.ctx, 1)
388
389 s.ctx.Request = httptest.NewRequest("GET", fmt.Sprintf("/plugin/%d/config", conf.ID), nil)
390 s.ctx.Params = gin.Params{{Key: "id", Value: fmt.Sprint(conf.ID)}}
391 s.a.GetConfig(s.ctx)
392
393 assert.Equal(s.T(), 200, s.recorder.Code)
394 returnedConfig := new(mock.PluginConfig)
395 assert.Nil(s.T(), yaml.Unmarshal(s.recorder.Body.Bytes(), returnedConfig))
396 assert.Equal(s.T(), mockInst.Config, returnedConfig)
397 }
398}
399
400func (s *PluginSuite) Test_GetConfg_notImplemeted_expect400() {
401 conf, err := s.db.GetPluginConfByUserAndPath(1, mock.ModulePath)

Callers

nothing calls this directly

Calls 5

WithUserFunction · 0.92
InstanceMethod · 0.80
GetConfigMethod · 0.80
DefaultConfigMethod · 0.65

Tested by

no test coverage detected