chore: support single queue and multiple worker (#589)

This commit is contained in:
Bo-Yi Wu
2021-07-16 12:10:34 +08:00
committed by GitHub
parent 0658f18430
commit ab8b1991ab
34 changed files with 1020 additions and 881 deletions

View File

@@ -3,16 +3,16 @@ package badger
import (
"testing"
c "github.com/appleboy/gorush/config"
"github.com/appleboy/gorush/config"
"github.com/stretchr/testify/assert"
)
func TestBadgerEngine(t *testing.T) {
var val int64
config, _ := c.LoadConf("")
cfg, _ := config.LoadConf()
badger := New(config)
badger := New(cfg)
err := badger.Init()
assert.Nil(t, err)
badger.Reset()

View File

@@ -3,16 +3,16 @@ package boltdb
import (
"testing"
c "github.com/appleboy/gorush/config"
"github.com/appleboy/gorush/config"
"github.com/stretchr/testify/assert"
)
func TestBoltDBEngine(t *testing.T) {
var val int64
config, _ := c.LoadConf("")
cfg, _ := config.LoadConf()
boltDB := New(config)
boltDB := New(cfg)
err := boltDB.Init()
assert.Nil(t, err)
boltDB.Reset()

View File

@@ -4,21 +4,21 @@ import (
"os"
"testing"
c "github.com/appleboy/gorush/config"
"github.com/appleboy/gorush/config"
"github.com/stretchr/testify/assert"
)
func TestBuntDBEngine(t *testing.T) {
var val int64
config, _ := c.LoadConf("")
cfg, _ := config.LoadConf()
if _, err := os.Stat(config.Stat.BuntDB.Path); os.IsNotExist(err) {
err := os.RemoveAll(config.Stat.BuntDB.Path)
if _, err := os.Stat(cfg.Stat.BuntDB.Path); os.IsNotExist(err) {
err := os.RemoveAll(cfg.Stat.BuntDB.Path)
assert.Nil(t, err)
}
buntDB := New(config)
buntDB := New(cfg)
err := buntDB.Init()
assert.Nil(t, err)
buntDB.Reset()

View File

@@ -4,21 +4,21 @@ import (
"os"
"testing"
c "github.com/appleboy/gorush/config"
"github.com/appleboy/gorush/config"
"github.com/stretchr/testify/assert"
)
func TestLevelDBEngine(t *testing.T) {
var val int64
config, _ := c.LoadConf("")
cfg, _ := config.LoadConf()
if _, err := os.Stat(config.Stat.LevelDB.Path); os.IsNotExist(err) {
err = os.RemoveAll(config.Stat.LevelDB.Path)
if _, err := os.Stat(cfg.Stat.LevelDB.Path); os.IsNotExist(err) {
err = os.RemoveAll(cfg.Stat.LevelDB.Path)
assert.Nil(t, err)
}
levelDB := New(config)
levelDB := New(cfg)
err := levelDB.Init()
assert.Nil(t, err)
levelDB.Reset()

View File

@@ -4,15 +4,15 @@ import (
"sync"
"testing"
c "github.com/appleboy/gorush/config"
"github.com/appleboy/gorush/config"
"github.com/stretchr/testify/assert"
)
func TestRedisServerError(t *testing.T) {
config, _ := c.LoadConf("")
config.Stat.Redis.Addr = "redis:6370"
cfg, _ := config.LoadConf()
cfg.Stat.Redis.Addr = "redis:6370"
redis := New(config)
redis := New(cfg)
err := redis.Init()
assert.Error(t, err)
@@ -21,10 +21,10 @@ func TestRedisServerError(t *testing.T) {
func TestRedisEngine(t *testing.T) {
var val int64
config, _ := c.LoadConf("")
config.Stat.Redis.Addr = "redis:6379"
cfg, _ := config.LoadConf()
cfg.Stat.Redis.Addr = "redis:6379"
redis := New(config)
redis := New(cfg)
err := redis.Init()
assert.Nil(t, err)
redis.Reset()