You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2021/06/22 06:38:52 UTC
[GitHub] [apisix-go-plugin-runner] tylitianrui commented on a change in pull request #10: concurrent safe map
tylitianrui commented on a change in pull request #10:
URL: https://github.com/apache/apisix-go-plugin-runner/pull/10#discussion_r655918191
##########
File path: internal/plugin/plugin_test.go
##########
@@ -94,10 +94,123 @@ func TestHTTPReqCall_FailedToParseConf(t *testing.T) {
}
func TestRegisterPlugin(t *testing.T) {
- assert.Equal(t, ErrMissingParseConfMethod,
- RegisterPlugin("bad_conf", nil, emptyFilter))
- assert.Equal(t, ErrMissingFilterMethod,
- RegisterPlugin("bad_conf", emptyParseConf, nil))
+ type args struct {
+ name string
+ pc ParseConfFunc
+ sv FilterFunc
+ }
+ tests := []struct {
+ name string
+ args args
+ wantErr error
+ }{
+ {
+ name: "test_MissingParseConfMethod",
+ args: args{
+ name: "1",
+ pc: nil,
+ sv: emptyFilter,
+ },
+ wantErr: ErrMissingParseConfMethod,
+ },
+ {
+ name: "test_MissingFilterMethod",
+ args: args{
+ name: "1",
+ pc: emptyParseConf,
+ sv: nil,
+ },
+ wantErr: ErrMissingFilterMethod,
+ },
+ {
+ name: "test_MissingParseConfMethod&FilterMethod",
+ args: args{
+ name: "1",
+ pc: nil,
+ sv: nil,
+ },
+ wantErr: ErrMissingParseConfMethod,
+ },
+ {
+ name: "test_MissingName&ParseConfMethod",
+ args: args{
+ name: "",
+ pc: nil,
+ sv: emptyFilter,
+ },
+ wantErr: ErrMissingName,
+ },
+ {
+ name: "test_MissingName&FilterMethod",
+ args: args{
+ name: "",
+ pc: emptyParseConf,
+ sv: nil,
+ },
+ wantErr: ErrMissingName,
+ },
+ {
+ name: "test_MissingAll",
+ args: args{
+ name: "",
+ pc: nil,
+ sv: nil,
+ },
+ wantErr: ErrMissingName,
+ },
+ {
+ name: "test_plugin1",
+ args: args{
+ name: "plugin1",
+ pc: emptyParseConf,
+ sv: emptyFilter,
+ },
+ wantErr: nil,
+ },
+ {
+ name: "test_plugin1_again",
+ args: args{
+ name: "plugin1",
+ pc: emptyParseConf,
+ sv: emptyFilter,
+ },
+ wantErr: ErrPluginRegistered{"plugin1"},
+ },
+ {
+ name: "test_plugin2",
+ args: args{
+ name: "plugin2111%#@#",
+ pc: emptyParseConf,
+ sv: emptyFilter,
+ },
+ wantErr: nil,
+ },
+ {
+ name: "test_plugin3",
+ args: args{
+ name: "plugin311*%#@#",
+ pc: emptyParseConf,
+ sv: emptyFilter,
+ },
+ wantErr: nil,
+ },
+ {
+ name: "test_plugin3_again",
+ args: args{
+ name: "plugin311*%#@#",
+ pc: emptyParseConf,
+ sv: emptyFilter,
+ },
+ wantErr: ErrPluginRegistered{"plugin311*%#@#"},
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ if err := RegisterPlugin(tt.args.name, tt.args.pc, tt.args.sv); !assert.Equal(t, tt.wantErr, err) {
Review comment:
it don't . thanks for your review 👍🏻 . TestRegisterPluginConcurrent does
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org