summaryrefslogtreecommitdiff
path: root/tests/plugins/kv/storage_plugin_test.go
diff options
context:
space:
mode:
authorValery Piashchynski <[email protected]>2021-09-13 15:40:57 +0300
committerGitHub <[email protected]>2021-09-13 15:40:57 +0300
commit5d2cd55ab522d4f1e65a833f91146444465a32ac (patch)
treea374c8e90383d5e868ffe6b44555a55029c54f79 /tests/plugins/kv/storage_plugin_test.go
parentfe72d84395970281fe330a2b9423f8c0e4c3b9c8 (diff)
parentb8a4b82f82e2cb9f9efc4a3601a97b4ff07fefc7 (diff)
[#793]: fix(plugins): incorrect parsing local and global drivers sections
[#793]: fix(plugins): incorrect parsing local and global drivers sections
Diffstat (limited to 'tests/plugins/kv/storage_plugin_test.go')
-rw-r--r--tests/plugins/kv/storage_plugin_test.go55
1 files changed, 13 insertions, 42 deletions
diff --git a/tests/plugins/kv/storage_plugin_test.go b/tests/plugins/kv/storage_plugin_test.go
index e757a9e6..c10e4726 100644
--- a/tests/plugins/kv/storage_plugin_test.go
+++ b/tests/plugins/kv/storage_plugin_test.go
@@ -10,6 +10,7 @@ import (
"testing"
"time"
+ "github.com/golang/mock/gomock"
endure "github.com/spiral/endure/pkg/container"
goridgeRpc "github.com/spiral/goridge/v3/pkg/rpc"
"github.com/spiral/roadrunner/v2/plugins/boltdb"
@@ -21,6 +22,7 @@ import (
"github.com/spiral/roadrunner/v2/plugins/redis"
rpcPlugin "github.com/spiral/roadrunner/v2/plugins/rpc"
payload "github.com/spiral/roadrunner/v2/proto/kv/v1beta"
+ "github.com/spiral/roadrunner/v2/tests/mocks"
"github.com/stretchr/testify/assert"
)
@@ -1293,12 +1295,21 @@ func TestRedisNoConfig(t *testing.T) {
Prefix: "rr",
}
+ controller := gomock.NewController(t)
+ mockLogger := mocks.NewMockLogger(controller)
+
+ mockLogger.EXPECT().Debug("worker destructed", "pid", gomock.Any()).AnyTimes()
+ mockLogger.EXPECT().Debug("worker constructed", "pid", gomock.Any()).AnyTimes()
+ mockLogger.EXPECT().Debug("Started RPC service", "address", "tcp://127.0.0.1:6001", "plugins", []string{"kv"}).AnyTimes()
+
+ mockLogger.EXPECT().Error(`can't find local or global configuration, this section will be skipped`, "local: ", "kv.redis-rr.config", "global: ", "redis-rr").Times(1)
+
err = cont.RegisterAll(
cfg,
&kv.Plugin{},
&redis.Plugin{},
&rpcPlugin.Plugin{},
- &logger.ZapLogger{},
+ mockLogger,
&memory.Plugin{},
)
assert.NoError(t, err)
@@ -1308,48 +1319,8 @@ func TestRedisNoConfig(t *testing.T) {
t.Fatal(err)
}
- ch, err := cont.Serve()
+ _, err = cont.Serve()
assert.NoError(t, err)
-
- sig := make(chan os.Signal, 1)
- signal.Notify(sig, os.Interrupt, syscall.SIGINT, syscall.SIGTERM)
-
- wg := &sync.WaitGroup{}
- wg.Add(1)
-
- stopCh := make(chan struct{}, 1)
-
- go func() {
- defer wg.Done()
- for {
- select {
- case e := <-ch:
- assert.Fail(t, "error", e.Error.Error())
- err = cont.Stop()
- if err != nil {
- assert.FailNow(t, "error", err.Error())
- }
- case <-sig:
- err = cont.Stop()
- if err != nil {
- assert.FailNow(t, "error", err.Error())
- }
- return
- case <-stopCh:
- // timeout
- err = cont.Stop()
- if err != nil {
- assert.FailNow(t, "error", err.Error())
- }
- return
- }
- }
- }()
-
- time.Sleep(time.Second * 1)
- t.Run("REDIS", testRPCMethodsRedis)
- stopCh <- struct{}{}
- wg.Wait()
}
func testRPCMethodsRedis(t *testing.T) {