1
0
mirror of https://github.com/redis/go-redis.git synced 2025-07-29 17:41:15 +03:00

Handle IPv6 in isMovedError (#2981)

* Handle IPv6 in isMovedError

* Simplify GetAddr

---------

Co-authored-by: Monkey <golang@88.com>
This commit is contained in:
Dávid Baláž
2024-04-28 06:37:44 +02:00
committed by GitHub
parent fa9edecebc
commit b64d9deef3
3 changed files with 41 additions and 0 deletions

View File

@ -51,3 +51,24 @@ func TestIsLower(t *testing.T) {
Expect(isLower(str)).To(BeTrue())
})
}
func TestGetAddr(t *testing.T) {
It("getAddr", func() {
str := "127.0.0.1:1234"
Expect(GetAddr(str)).To(Equal(str))
str = "[::1]:1234"
Expect(GetAddr(str)).To(Equal(str))
str = "[fd01:abcd::7d03]:6379"
Expect(GetAddr(str)).To(Equal(str))
Expect(GetAddr("::1:1234")).To(Equal("[::1]:1234"))
Expect(GetAddr("fd01:abcd::7d03:6379")).To(Equal("[fd01:abcd::7d03]:6379"))
Expect(GetAddr("127.0.0.1")).To(Equal(""))
Expect(GetAddr("127")).To(Equal(""))
})
}