Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Marc Audefroy <marc.audefroy@corp.ovh.com>
- Loading branch information
1 parent
bd5b3d4
commit 1a1a507
Showing
382 changed files
with
18,142 additions
and
5,764 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() | ||
} |
Oops, something went wrong.