Skip to content

Commit

Permalink
feat: Add redis executor (#141)
Browse files Browse the repository at this point in the history
Signed-off-by: Marc Audefroy <marc.audefroy@corp.ovh.com>
  • Loading branch information
marcaudefroy authored and fsamin committed Apr 4, 2018
1 parent bd5b3d4 commit 1a1a507
Show file tree
Hide file tree
Showing 382 changed files with 18,142 additions and 5,764 deletions.
135 changes: 52 additions & 83 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions cli/venom/run/cmd.go
Expand Up @@ -16,13 +16,16 @@ import (

"github.com/ovh/venom"
"github.com/ovh/venom/context/default"
"github.com/ovh/venom/context/redis"
"github.com/ovh/venom/context/webctx"

"github.com/ovh/venom/executors/dbfixtures"
"github.com/ovh/venom/executors/exec"
"github.com/ovh/venom/executors/http"
"github.com/ovh/venom/executors/imap"
"github.com/ovh/venom/executors/ovhapi"
"github.com/ovh/venom/executors/readfile"
"github.com/ovh/venom/executors/redis"
"github.com/ovh/venom/executors/smtp"
"github.com/ovh/venom/executors/ssh"
"github.com/ovh/venom/executors/web"
Expand Down Expand Up @@ -84,10 +87,12 @@ var Cmd = &cobra.Command{
v.RegisterExecutor(web.Name, web.New())
v.RegisterExecutor(ovhapi.Name, ovhapi.New())
v.RegisterExecutor(dbfixtures.Name, dbfixtures.New())
v.RegisterExecutor(redis.Name, redis.New())

// Register Context
v.RegisterTestCaseContext(defaultctx.Name, defaultctx.New())
v.RegisterTestCaseContext(webctx.Name, webctx.New())
v.RegisterTestCaseContext(redisctx.Name, redisctx.New())

},
Run: func(cmd *cobra.Command, args []string) {
Expand Down
53 changes: 53 additions & 0 deletions context/redis/context.go
@@ -0,0 +1,53 @@
package redisctx

import (
"fmt"

"github.com/garyburd/redigo/redis"
"github.com/ovh/venom"
)

// Name is Context Type name.
const Name = "redis"

//Client represents interface of redis client used by venom
type Client interface {
Close() error
Do(commandName string, args ...interface{}) (reply interface{}, err error)
}

// New returns a new TestCaseContext.
func New() venom.TestCaseContext {
ctx := &RedisTestCaseContext{}
ctx.Name = Name
return ctx
}

// RedisTestCaseContext represents the context of a testcase.
type RedisTestCaseContext struct {
venom.CommonTestCaseContext
Client Client
}

// Init Initialize the context.
func (tcc *RedisTestCaseContext) Init() error {
var dialURL string
if v, found := tcc.TestCase.Context["dialURL"]; found {
if url, ok := v.(string); ok {
dialURL = url
} else {
return fmt.Errorf("DialURL property must be a string")
}
} else {
return fmt.Errorf("DialURL property isn't present")
}

var err error
tcc.Client, err = redis.DialURL(dialURL)
return err
}

// Close the context.
func (tcc *RedisTestCaseContext) Close() error {
return tcc.Client.Close()
}

0 comments on commit 1a1a507

Please sign in to comment.