Chore: Remove unused Go code (#28852)

* Chore: Remove more unused Go code

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
This commit is contained in:
Arve Knudsen
2020-11-17 11:51:31 +01:00
committed by GitHub
parent 8c765e8068
commit 4dd7b7a82d
47 changed files with 44 additions and 381 deletions
+13 -5
View File
@@ -9,9 +9,17 @@ import (
"github.com/grafana/grafana/pkg/components/securejsondata"
)
// clearPluginSettingDecryptionCache clears the datasource decryption cache.
func clearPluginSettingDecryptionCache() {
pluginSettingDecryptionCache.Lock()
defer pluginSettingDecryptionCache.Unlock()
pluginSettingDecryptionCache.cache = make(map[int64]cachedDecryptedJSON)
}
func TestPluginSettingDecryptionCache(t *testing.T) {
t.Run("When plugin settings hasn't been updated, encrypted JSON should be fetched from cache", func(t *testing.T) {
ClearPluginSettingDecryptionCache()
clearPluginSettingDecryptionCache()
ps := PluginSetting{
Id: 1,
@@ -22,7 +30,7 @@ func TestPluginSettingDecryptionCache(t *testing.T) {
}
// Populate cache
password, ok := ps.DecryptedValue("password")
password, ok := ps.DecryptedValues()["password"]
require.Equal(t, "password", password)
require.True(t, ok)
@@ -35,7 +43,7 @@ func TestPluginSettingDecryptionCache(t *testing.T) {
})
t.Run("When plugin settings is updated, encrypted JSON should not be fetched from cache", func(t *testing.T) {
ClearPluginSettingDecryptionCache()
clearPluginSettingDecryptionCache()
ps := PluginSetting{
Id: 1,
@@ -46,7 +54,7 @@ func TestPluginSettingDecryptionCache(t *testing.T) {
}
// Populate cache
password, ok := ps.DecryptedValue("password")
password, ok := ps.DecryptedValues()["password"]
require.Equal(t, "password", password)
require.True(t, ok)
@@ -55,7 +63,7 @@ func TestPluginSettingDecryptionCache(t *testing.T) {
})
ps.Updated = time.Now()
password, ok = ps.DecryptedValue("password")
password, ok = ps.DecryptedValues()["password"]
require.Empty(t, password)
require.True(t, ok)
})