mirror of
https://github.com/redis/go-redis.git
synced 2025-04-19 07:22:17 +03:00
Allowing for running tests on a port other than the fixed 6380 (#2466)
* Allowing for redis on a specified port * updating the readme --------- Co-authored-by: Vladimir Mihailenco <vladimir.webdev@gmail.com> Co-authored-by: Monkey <golang@88.com>
This commit is contained in:
parent
ad89a97fdc
commit
cbfe6cd076
@ -167,6 +167,12 @@ Lastly, run:
|
|||||||
go test
|
go test
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Another option is to run your specific tests with an already running redis. The example below, tests against a redis running on port 9999.:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
REDIS_PORT=9999 go test <your options>
|
||||||
|
```
|
||||||
|
|
||||||
## See also
|
## See also
|
||||||
|
|
||||||
- [Golang ORM](https://bun.uptrace.dev) for PostgreSQL, MySQL, MSSQL, and SQLite
|
- [Golang ORM](https://bun.uptrace.dev) for PostgreSQL, MySQL, MSSQL, and SQLite
|
||||||
|
10
main_test.go
10
main_test.go
@ -17,8 +17,6 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
redisPort = "6380"
|
|
||||||
redisAddr = ":" + redisPort
|
|
||||||
redisSecondaryPort = "6381"
|
redisSecondaryPort = "6381"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -38,6 +36,9 @@ const (
|
|||||||
sentinelPort3 = "9128"
|
sentinelPort3 = "9128"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var redisPort = "6380"
|
||||||
|
var redisAddr = ":" + redisPort
|
||||||
|
|
||||||
var (
|
var (
|
||||||
sentinelAddrs = []string{":" + sentinelPort1, ":" + sentinelPort2, ":" + sentinelPort3}
|
sentinelAddrs = []string{":" + sentinelPort1, ":" + sentinelPort2, ":" + sentinelPort3}
|
||||||
|
|
||||||
@ -64,6 +65,11 @@ func registerProcess(port string, p *redisProcess) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var _ = BeforeSuite(func() {
|
var _ = BeforeSuite(func() {
|
||||||
|
addr := os.Getenv("REDIS_PORT")
|
||||||
|
if addr != "" {
|
||||||
|
redisPort = addr
|
||||||
|
redisAddr = ":" + redisPort
|
||||||
|
}
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
redisMain, err = startRedis(redisPort)
|
redisMain, err = startRedis(redisPort)
|
||||||
|
@ -4,6 +4,7 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
@ -64,7 +65,7 @@ var _ = Describe("Client", func() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
It("should Stringer", func() {
|
It("should Stringer", func() {
|
||||||
Expect(client.String()).To(Equal("Redis<:6380 db:15>"))
|
Expect(client.String()).To(Equal(fmt.Sprintf("Redis<:%s db:15>", redisPort)))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("supports context", func() {
|
It("supports context", func() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user