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

Function TestRequirePluginEnabled

plugin/pluginenabled_test.go:13–42  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

11)
12
13func TestRequirePluginEnabled(t *testing.T) {
14 db := testdb.NewDBWithDefaultUser(t)
15 conf := &model.PluginConf{
16 ID: 1,
17 UserID: 1,
18 Enabled: true,
19 }
20 db.CreatePluginConf(conf)
21
22 g := gin.New()
23
24 mux := g.Group("/", requirePluginEnabled(1, db))
25
26 mux.GET("/", func(c *gin.Context) {
27 c.Status(200)
28 })
29
30 getCode := func() int {
31 r := httptest.NewRequest("GET", "/", nil)
32 w := httptest.NewRecorder()
33 g.ServeHTTP(w, r)
34 return w.Code
35 }
36
37 assert.Equal(t, 200, getCode())
38
39 conf.Enabled = false
40 db.UpdatePluginConf(conf)
41 assert.Equal(t, 400, getCode())
42}

Callers

nothing calls this directly

Calls 4

NewDBWithDefaultUserFunction · 0.92
requirePluginEnabledFunction · 0.85
CreatePluginConfMethod · 0.65
UpdatePluginConfMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…