(t *testing.T)
| 176 | } |
| 177 | |
| 178 | func TestLoadPluginSkipError(t *testing.T) { |
| 179 | ctx := context.Background() |
| 180 | |
| 181 | pluginName := "tplugin" |
| 182 | pluginVersion := uint16(1) |
| 183 | pluginSign := pluginName + "-" + strconv.Itoa(int(pluginVersion)) |
| 184 | |
| 185 | cfg := Config{ |
| 186 | Plugins: []string{pluginSign, pluginSign, "notExists-2"}, |
| 187 | PluginDir: "", |
| 188 | EnvVersion: map[string]uint16{"go": 1112}, |
| 189 | SkipWhenFail: true, |
| 190 | } |
| 191 | |
| 192 | // setup load test hook. |
| 193 | SetTestHook(func(plugin *Plugin, dir string, pluginID ID) (manifest func() *Manifest, err error) { |
| 194 | return func() *Manifest { |
| 195 | m := &AuditManifest{ |
| 196 | Manifest: Manifest{ |
| 197 | Kind: Audit, |
| 198 | Name: pluginName, |
| 199 | Version: pluginVersion, |
| 200 | OnInit: func(ctx context.Context, manifest *Manifest) error { |
| 201 | return io.EOF |
| 202 | }, |
| 203 | OnShutdown: func(ctx context.Context, manifest *Manifest) error { |
| 204 | return io.EOF |
| 205 | }, |
| 206 | Validate: func(ctx context.Context, manifest *Manifest) error { |
| 207 | return io.EOF |
| 208 | }, |
| 209 | }, |
| 210 | OnGeneralEvent: func(ctx context.Context, sctx *variable.SessionVars, event GeneralEvent, cmd string) { |
| 211 | }, |
| 212 | } |
| 213 | return ExportManifest(m) |
| 214 | }, nil |
| 215 | }) |
| 216 | defer func() { |
| 217 | testHook = nil |
| 218 | }() |
| 219 | |
| 220 | // trigger load. |
| 221 | err := Load(ctx, cfg) |
| 222 | require.NoError(t, err) |
| 223 | |
| 224 | err = Init(ctx, cfg) |
| 225 | require.NoError(t, err) |
| 226 | require.False(t, IsEnable(Audit)) |
| 227 | |
| 228 | // load all. |
| 229 | ps := GetAll() |
| 230 | require.Len(t, ps, 1) |
| 231 | |
| 232 | // find plugin by type and name |
| 233 | p := Get(Audit, "tplugin") |
| 234 | require.NotNil(t, p) |
| 235 | p = Get(Audit, "tplugin2") |
nothing calls this directly
no test coverage detected