()
| 98 | } |
| 99 | |
| 100 | func (s *PluginSuite) Test_EnableDisablePlugin() { |
| 101 | { |
| 102 | test.WithUser(s.ctx, 1) |
| 103 | |
| 104 | s.ctx.Request = httptest.NewRequest("POST", "/plugin/1/enable", nil) |
| 105 | s.ctx.Params = gin.Params{{Key: "id", Value: "1"}} |
| 106 | s.a.EnablePlugin(s.ctx) |
| 107 | |
| 108 | assert.Equal(s.T(), 200, s.recorder.Code) |
| 109 | |
| 110 | if pluginConf, err := s.db.GetPluginConfByUserAndPath(1, mock.ModulePath); assert.NoError(s.T(), err) { |
| 111 | assert.True(s.T(), pluginConf.Enabled) |
| 112 | } |
| 113 | s.resetRecorder() |
| 114 | } |
| 115 | |
| 116 | { |
| 117 | test.WithUser(s.ctx, 1) |
| 118 | |
| 119 | s.ctx.Request = httptest.NewRequest("POST", "/plugin/1/enable", nil) |
| 120 | s.ctx.Params = gin.Params{{Key: "id", Value: "1"}} |
| 121 | s.a.EnablePlugin(s.ctx) |
| 122 | |
| 123 | assert.Equal(s.T(), 400, s.recorder.Code) |
| 124 | |
| 125 | if pluginConf, err := s.db.GetPluginConfByUserAndPath(1, mock.ModulePath); assert.NoError(s.T(), err) { |
| 126 | assert.True(s.T(), pluginConf.Enabled) |
| 127 | } |
| 128 | s.resetRecorder() |
| 129 | } |
| 130 | |
| 131 | { |
| 132 | test.WithUser(s.ctx, 1) |
| 133 | |
| 134 | s.ctx.Request = httptest.NewRequest("POST", "/plugin/1/disable", nil) |
| 135 | s.ctx.Params = gin.Params{{Key: "id", Value: "1"}} |
| 136 | s.a.DisablePlugin(s.ctx) |
| 137 | |
| 138 | assert.Equal(s.T(), 200, s.recorder.Code) |
| 139 | |
| 140 | if pluginConf, err := s.db.GetPluginConfByUserAndPath(1, mock.ModulePath); assert.NoError(s.T(), err) { |
| 141 | assert.False(s.T(), pluginConf.Enabled) |
| 142 | } |
| 143 | s.resetRecorder() |
| 144 | } |
| 145 | |
| 146 | { |
| 147 | test.WithUser(s.ctx, 1) |
| 148 | |
| 149 | s.ctx.Request = httptest.NewRequest("POST", "/plugin/1/disable", nil) |
| 150 | s.ctx.Params = gin.Params{{Key: "id", Value: "1"}} |
| 151 | s.a.DisablePlugin(s.ctx) |
| 152 | |
| 153 | assert.Equal(s.T(), 400, s.recorder.Code) |
| 154 | |
| 155 | if pluginConf, err := s.db.GetPluginConfByUserAndPath(1, mock.ModulePath); assert.NoError(s.T(), err) { |
| 156 | assert.False(s.T(), pluginConf.Enabled) |
| 157 | } |
nothing calls this directly
no test coverage detected