mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
Make datastore tests pass with remote Docker containers (#587)
* Make datastore tests pass with remote Docker containers * Make tests consume DOCKER_HOST IP address as bind host while constucting database URI. This fix makes datastore tests pass against remote Docker (with host IP different from 127.0.0.1) Fixes: #586 * Make datastore tests pass on Go1.7.1
This commit is contained in:
committed by
Seif Lotfy سيف لطفي
parent
c38aae4bfe
commit
23360d45f3
@@ -13,7 +13,7 @@ import (
|
||||
"github.com/iron-io/functions/api/datastore/internal/datastoretest"
|
||||
)
|
||||
|
||||
const tmpRedis = "redis://127.0.0.1:6301/"
|
||||
const tmpRedis = "redis://%v:6301/"
|
||||
|
||||
func prepareRedisTest(logf, fatalf func(string, ...interface{})) (func(), func()) {
|
||||
fmt.Println("initializing redis for test")
|
||||
@@ -22,7 +22,7 @@ func prepareRedisTest(logf, fatalf func(string, ...interface{})) (func(), func()
|
||||
timeout := time.After(20 * time.Second)
|
||||
|
||||
for {
|
||||
c, err := redis.DialURL(tmpRedis)
|
||||
c, err := redis.DialURL(fmt.Sprintf(tmpRedis, datastoretest.GetContainerHostIP()))
|
||||
if err == nil {
|
||||
_, err = c.Do("PING")
|
||||
c.Close()
|
||||
@@ -49,7 +49,7 @@ func TestDatastore(t *testing.T) {
|
||||
_, close := prepareRedisTest(t.Logf, t.Fatalf)
|
||||
defer close()
|
||||
|
||||
u, err := url.Parse(tmpRedis)
|
||||
u, err := url.Parse(fmt.Sprintf(tmpRedis, datastoretest.GetContainerHostIP()))
|
||||
if err != nil {
|
||||
t.Fatal("failed to parse url: ", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user