فهرست منبع

Rename DialTest to DialTestDB.

Also, add doc comments to the dial() and DialTestDB() functions.
Gary Burd 11 سال پیش
والد
کامیت
e2941976df
6فایلهای تغییر یافته به همراه13 افزوده شده و 9 حذف شده
  1. 4 4
      redis/conn_test.go
  2. 1 1
      redis/pool_test.go
  3. 1 1
      redis/pubsub_test.go
  4. 2 1
      redis/reply_test.go
  5. 1 1
      redis/script_test.go
  6. 4 1
      redis/test_test.go

+ 4 - 4
redis/conn_test.go

@@ -221,7 +221,7 @@ var testCommands = []struct {
 }
 
 func TestDoCommands(t *testing.T) {
-	c, err := redis.DialTest()
+	c, err := redis.DialTestDB()
 	if err != nil {
 		t.Fatalf("error connection to database, %v", err)
 	}
@@ -240,7 +240,7 @@ func TestDoCommands(t *testing.T) {
 }
 
 func TestPipelineCommands(t *testing.T) {
-	c, err := redis.DialTest()
+	c, err := redis.DialTestDB()
 	if err != nil {
 		t.Fatalf("error connection to database, %v", err)
 	}
@@ -266,7 +266,7 @@ func TestPipelineCommands(t *testing.T) {
 }
 
 func TestBlankCommmand(t *testing.T) {
-	c, err := redis.DialTest()
+	c, err := redis.DialTestDB()
 	if err != nil {
 		t.Fatalf("error connection to database, %v", err)
 	}
@@ -293,7 +293,7 @@ func TestBlankCommmand(t *testing.T) {
 }
 
 func TestError(t *testing.T) {
-	c, err := redis.DialTest()
+	c, err := redis.DialTestDB()
 	if err != nil {
 		t.Fatalf("error connection to database, %v", err)
 	}

+ 1 - 1
redis/pool_test.go

@@ -54,7 +54,7 @@ type poolDialer struct {
 func (d *poolDialer) dial() (Conn, error) {
 	d.open += 1
 	d.dialed += 1
-	c, err := DialTest()
+	c, err := DialTestDB()
 	if err != nil {
 		return nil, err
 	}

+ 1 - 1
redis/pubsub_test.go

@@ -109,7 +109,7 @@ func expectPushed(t *testing.T, c redis.PubSubConn, message string, expected int
 }
 
 func TestPushed(t *testing.T) {
-	pc, err := redis.DialTest()
+	pc, err := redis.DialTestDB()
 	if err != nil {
 		t.Fatalf("error connection to database, %v", err)
 	}

+ 2 - 1
redis/reply_test.go

@@ -80,8 +80,9 @@ func TestReply(t *testing.T) {
 	}
 }
 
+// dial wraps DialTestDB() with a more suitable function name for examples.
 func dial() (redis.Conn, error) {
-	return redis.DialTest()
+	return redis.DialTestDB()
 }
 
 func ExampleBool() {

+ 1 - 1
redis/script_test.go

@@ -33,7 +33,7 @@ func ExampleScript(c redis.Conn, reply interface{}, err error) {
 }
 
 func TestScript(t *testing.T) {
-	c, err := redis.DialTest()
+	c, err := redis.DialTestDB()
 	if err != nil {
 		t.Fatalf("error connection to database, %v", err)
 	}

+ 4 - 1
redis/test_test.go

@@ -37,7 +37,10 @@ func (t testConn) Close() error {
 	return t.Conn.Close()
 }
 
-func DialTest() (Conn, error) {
+// DialTestDB dials the local Redis server and selects database 9. To prevent
+// stomping on real data, DialTestDB fails if database 9 contains data. The
+// returned connection flushes database 9 on close.
+func DialTestDB() (Conn, error) {
 	c, err := DialTimeout("tcp", ":6379", 0, 1*time.Second, 1*time.Second)
 	if err != nil {
 		return nil, err