@@ -2,6 +2,8 @@ package rdb_test
22
33import (
44 "fmt"
5+ "net"
6+ "strconv"
57 "testing"
68
79 "github.com/scaleway/scaleway-cli/v2/internal/core"
@@ -21,7 +23,7 @@ func Test_UserGetURL(t *testing.T) {
2123 func (t * testing.T , ctx * core.CheckFuncCtx ) {
2224 ip := ctx .Meta ["Instance" ].(rdb.CreateInstanceResult ).Instance .Endpoints [0 ].IP
2325 port := ctx .Meta ["Instance" ].(rdb.CreateInstanceResult ).Instance .Endpoints [0 ].Port
24- expected := fmt .Sprintf ("postgresql://%s@%s:%d " , user , ip , port )
26+ expected := fmt .Sprintf ("postgresql://%s@%s" , user , net . JoinHostPort ( ip . String (), strconv . Itoa ( int ( port ))) )
2527 assert .Equal (t , expected , ctx .Result )
2628 },
2729 ),
@@ -39,7 +41,7 @@ func Test_UserGetURL(t *testing.T) {
3941 func (t * testing.T , ctx * core.CheckFuncCtx ) {
4042 ip := ctx .Meta ["Instance" ].(rdb.CreateInstanceResult ).Instance .Endpoints [0 ].IP
4143 port := ctx .Meta ["Instance" ].(rdb.CreateInstanceResult ).Instance .Endpoints [0 ].Port
42- expected := fmt .Sprintf ("mysql://%s@%s:%d " , user , ip , port )
44+ expected := fmt .Sprintf ("mysql://%s@%s" , user , net . JoinHostPort ( ip . String (), strconv . Itoa ( int ( port ))) )
4345 assert .Equal (t , expected , ctx .Result )
4446 },
4547 ),
@@ -62,7 +64,7 @@ func Test_UserGetURL(t *testing.T) {
6264 func (t * testing.T , ctx * core.CheckFuncCtx ) {
6365 ip := ctx .Meta ["Instance" ].(rdb.CreateInstanceResult ).Instance .Endpoints [0 ].IP
6466 port := ctx .Meta ["Instance" ].(rdb.CreateInstanceResult ).Instance .Endpoints [0 ].Port
65- expected := fmt .Sprintf ("postgresql://%s@%s:%d " , customUserName , ip , port )
67+ expected := fmt .Sprintf ("postgresql://%s@%s" , customUserName , net . JoinHostPort ( ip . String (), strconv . Itoa ( int ( port ))) )
6668 assert .Equal (t , expected , ctx .Result )
6769 },
6870 ),
@@ -81,7 +83,7 @@ func Test_UserGetURL(t *testing.T) {
8183 func (t * testing.T , ctx * core.CheckFuncCtx ) {
8284 ip := ctx .Meta ["Instance" ].(rdb.CreateInstanceResult ).Instance .Endpoints [0 ].IP
8385 port := ctx .Meta ["Instance" ].(rdb.CreateInstanceResult ).Instance .Endpoints [0 ].Port
84- expected := fmt .Sprintf ("postgresql://%s@%s:%d /%s" , user , ip , port , customDBName )
86+ expected := fmt .Sprintf ("postgresql://%s@%s/%s" , user , net . JoinHostPort ( ip . String (), strconv . Itoa ( int ( port ))) , customDBName )
8587 assert .Equal (t , expected , ctx .Result )
8688 },
8789 ),
@@ -101,7 +103,7 @@ func Test_DatabaseGetURL(t *testing.T) {
101103 func (t * testing.T , ctx * core.CheckFuncCtx ) {
102104 ip := ctx .Meta ["Instance" ].(rdb.CreateInstanceResult ).Instance .Endpoints [0 ].IP
103105 port := ctx .Meta ["Instance" ].(rdb.CreateInstanceResult ).Instance .Endpoints [0 ].Port
104- expected := fmt .Sprintf ("postgresql://%s@%s:%d " , user , ip , port )
106+ expected := fmt .Sprintf ("postgresql://%s@%s" , user , net . JoinHostPort ( ip . String (), strconv . Itoa ( int ( port ))) )
105107 assert .Equal (t , expected , ctx .Result )
106108 },
107109 ),
0 commit comments