Fixed a possible nil pointer dereference caused by variable plug

This commit is contained in:
mengjiao.liu
2021-04-01 17:36:33 +08:00
committed by Mengjiao Liu
parent 5de1a754c8
commit c24b87b133
22 changed files with 47 additions and 47 deletions

View File

@@ -308,7 +308,7 @@ func TestCanSupport(t *testing.T) {
plugin, err := pluginMgr.FindPluginByName(configMapPluginName)
if err != nil {
t.Errorf("Can't find the plugin by name")
t.Fatal("Can't find the plugin by name")
}
if plugin.GetPluginName() != configMapPluginName {
t.Errorf("Wrong name: %s", plugin.GetPluginName())
@@ -340,7 +340,7 @@ func TestPlugin(t *testing.T) {
plugin, err := pluginMgr.FindPluginByName(configMapPluginName)
if err != nil {
t.Errorf("Can't find the plugin by name")
t.Fatal("Can't find the plugin by name")
}
pod := &v1.Pod{ObjectMeta: metav1.ObjectMeta{Namespace: testNamespace, UID: testPodUID}}
@@ -406,7 +406,7 @@ func TestPluginReboot(t *testing.T) {
plugin, err := pluginMgr.FindPluginByName(configMapPluginName)
if err != nil {
t.Errorf("Can't find the plugin by name")
t.Fatal("Can't find the plugin by name")
}
pod := &v1.Pod{ObjectMeta: metav1.ObjectMeta{Namespace: testNamespace, UID: testPodUID}}
@@ -464,7 +464,7 @@ func TestPluginOptional(t *testing.T) {
plugin, err := pluginMgr.FindPluginByName(configMapPluginName)
if err != nil {
t.Errorf("Can't find the plugin by name")
t.Fatal("Can't find the plugin by name")
}
pod := &v1.Pod{ObjectMeta: metav1.ObjectMeta{Namespace: testNamespace, UID: testPodUID}}
@@ -563,7 +563,7 @@ func TestPluginKeysOptional(t *testing.T) {
plugin, err := pluginMgr.FindPluginByName(configMapPluginName)
if err != nil {
t.Errorf("Can't find the plugin by name")
t.Fatal("Can't find the plugin by name")
}
pod := &v1.Pod{ObjectMeta: metav1.ObjectMeta{Namespace: testNamespace, UID: testPodUID}}
@@ -643,7 +643,7 @@ func TestInvalidConfigMapSetup(t *testing.T) {
plugin, err := pluginMgr.FindPluginByName(configMapPluginName)
if err != nil {
t.Errorf("Can't find the plugin by name")
t.Fatal("Can't find the plugin by name")
}
pod := &v1.Pod{ObjectMeta: metav1.ObjectMeta{Namespace: testNamespace, UID: testPodUID}}