mirror of
https://github.com/grafana/grafana.git
synced 2025-07-28 19:02:29 +08:00
Plugins: Create single point of entry for adding / removing plugins (#55463)
* split out plugin manager * remove whitespace * fix tests * split up tests * updating naming conventions * simplify manager * tidy * explorations * fix build * tidy * fix tests * add logger helper * pass the tests * tidying * fix tests * tidy and re-add test * store depends on loader * enrich tests * fix test * undo gomod changes
This commit is contained in:
@ -51,16 +51,14 @@ func Test_PluginsInstallAndUninstall(t *testing.T) {
|
||||
action, testCase.expectedHTTPStatus, testCase.pluginAdminEnabled, testCase.pluginAdminExternalManageEnabled)
|
||||
}
|
||||
|
||||
pm := &fakePluginManager{
|
||||
plugins: make(map[string]fakePlugin),
|
||||
}
|
||||
inst := NewFakePluginInstaller()
|
||||
for _, tc := range tcs {
|
||||
srv := SetupAPITestServer(t, func(hs *HTTPServer) {
|
||||
hs.Cfg = &setting.Cfg{
|
||||
PluginAdminEnabled: tc.pluginAdminEnabled,
|
||||
PluginAdminExternalManageEnabled: tc.pluginAdminExternalManageEnabled,
|
||||
}
|
||||
hs.pluginManager = pm
|
||||
hs.pluginInstaller = inst
|
||||
hs.QuotaService = quotatest.NewQuotaServiceFake()
|
||||
})
|
||||
|
||||
@ -78,7 +76,7 @@ func Test_PluginsInstallAndUninstall(t *testing.T) {
|
||||
require.Equal(t, tc.expectedHTTPStatus, resp.StatusCode)
|
||||
|
||||
if tc.expectedHTTPStatus == 200 {
|
||||
require.Equal(t, fakePlugin{pluginID: "test", version: "1.0.2"}, pm.plugins["test"])
|
||||
require.Equal(t, fakePlugin{pluginID: "test", version: "1.0.2"}, inst.plugins["test"])
|
||||
}
|
||||
})
|
||||
|
||||
@ -96,7 +94,7 @@ func Test_PluginsInstallAndUninstall(t *testing.T) {
|
||||
require.Equal(t, tc.expectedHTTPStatus, resp.StatusCode)
|
||||
|
||||
if tc.expectedHTTPStatus == 200 {
|
||||
require.Empty(t, pm.plugins)
|
||||
require.Empty(t, inst.plugins)
|
||||
}
|
||||
})
|
||||
}
|
||||
@ -125,10 +123,6 @@ func Test_PluginsInstallAndUninstall_AccessControl(t *testing.T) {
|
||||
action, tc.expectedCode, tc.pluginAdminEnabled, tc.pluginAdminExternalManageEnabled, tc.permissions)
|
||||
}
|
||||
|
||||
pm := &fakePluginManager{
|
||||
plugins: make(map[string]fakePlugin),
|
||||
}
|
||||
|
||||
for _, tc := range tcs {
|
||||
sc := setupHTTPServerWithCfg(t, true, &setting.Cfg{
|
||||
RBACEnabled: true,
|
||||
@ -136,7 +130,7 @@ func Test_PluginsInstallAndUninstall_AccessControl(t *testing.T) {
|
||||
PluginAdminExternalManageEnabled: tc.pluginAdminExternalManageEnabled})
|
||||
setInitCtxSignedInViewer(sc.initCtx)
|
||||
setAccessControlPermissions(sc.acmock, tc.permissions, sc.initCtx.OrgID)
|
||||
sc.hs.pluginManager = pm
|
||||
sc.hs.pluginInstaller = NewFakePluginInstaller()
|
||||
|
||||
t.Run(testName("Install", tc), func(t *testing.T) {
|
||||
input := strings.NewReader("{ \"version\": \"1.0.2\" }")
|
||||
|
Reference in New Issue
Block a user