Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ linters:
- musttag # enforce field tags in (un)marshaled structs [fast: false, auto-fix: false]
- nakedret # Finds naked returns in functions greater than a specified function length [fast: true, auto-fix: false]
- nolintlint # Reports ill-formed or insufficient nolint directives [fast: true, auto-fix: false]
- nosprintfhostport # Checks for misuse of Sprintf to construct a host with port in a URL. [fast: true, auto-fix: false]
- prealloc # Finds slice declarations that could potentially be pre-allocated [fast: true, auto-fix: false]
- predeclared # find code that shadows one of Go's predeclared identifiers [fast: true, auto-fix: false]
- promlinter # Check Prometheus metrics naming via promlint [fast: true, auto-fix: false]
Expand Down
12 changes: 7 additions & 5 deletions internal/namespaces/rdb/v1/custom_url_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package rdb_test

import (
"fmt"
"net"
"strconv"
"testing"

"github.com/scaleway/scaleway-cli/v2/internal/core"
Expand All @@ -21,7 +23,7 @@ func Test_UserGetURL(t *testing.T) {
func(t *testing.T, ctx *core.CheckFuncCtx) {
ip := ctx.Meta["Instance"].(rdb.CreateInstanceResult).Instance.Endpoints[0].IP
port := ctx.Meta["Instance"].(rdb.CreateInstanceResult).Instance.Endpoints[0].Port
expected := fmt.Sprintf("postgresql://%s@%s:%d", user, ip, port)
expected := fmt.Sprintf("postgresql://%s@%s", user, net.JoinHostPort(ip.String(), strconv.Itoa(int(port))))
assert.Equal(t, expected, ctx.Result)
},
),
Expand All @@ -39,7 +41,7 @@ func Test_UserGetURL(t *testing.T) {
func(t *testing.T, ctx *core.CheckFuncCtx) {
ip := ctx.Meta["Instance"].(rdb.CreateInstanceResult).Instance.Endpoints[0].IP
port := ctx.Meta["Instance"].(rdb.CreateInstanceResult).Instance.Endpoints[0].Port
expected := fmt.Sprintf("mysql://%s@%s:%d", user, ip, port)
expected := fmt.Sprintf("mysql://%s@%s", user, net.JoinHostPort(ip.String(), strconv.Itoa(int(port))))
assert.Equal(t, expected, ctx.Result)
},
),
Expand All @@ -62,7 +64,7 @@ func Test_UserGetURL(t *testing.T) {
func(t *testing.T, ctx *core.CheckFuncCtx) {
ip := ctx.Meta["Instance"].(rdb.CreateInstanceResult).Instance.Endpoints[0].IP
port := ctx.Meta["Instance"].(rdb.CreateInstanceResult).Instance.Endpoints[0].Port
expected := fmt.Sprintf("postgresql://%s@%s:%d", customUserName, ip, port)
expected := fmt.Sprintf("postgresql://%s@%s", customUserName, net.JoinHostPort(ip.String(), strconv.Itoa(int(port))))
assert.Equal(t, expected, ctx.Result)
},
),
Expand All @@ -81,7 +83,7 @@ func Test_UserGetURL(t *testing.T) {
func(t *testing.T, ctx *core.CheckFuncCtx) {
ip := ctx.Meta["Instance"].(rdb.CreateInstanceResult).Instance.Endpoints[0].IP
port := ctx.Meta["Instance"].(rdb.CreateInstanceResult).Instance.Endpoints[0].Port
expected := fmt.Sprintf("postgresql://%s@%s:%d/%s", user, ip, port, customDBName)
expected := fmt.Sprintf("postgresql://%s@%s/%s", user, net.JoinHostPort(ip.String(), strconv.Itoa(int(port))), customDBName)
assert.Equal(t, expected, ctx.Result)
},
),
Expand All @@ -101,7 +103,7 @@ func Test_DatabaseGetURL(t *testing.T) {
func(t *testing.T, ctx *core.CheckFuncCtx) {
ip := ctx.Meta["Instance"].(rdb.CreateInstanceResult).Instance.Endpoints[0].IP
port := ctx.Meta["Instance"].(rdb.CreateInstanceResult).Instance.Endpoints[0].Port
expected := fmt.Sprintf("postgresql://%s@%s:%d", user, ip, port)
expected := fmt.Sprintf("postgresql://%s@%s", user, net.JoinHostPort(ip.String(), strconv.Itoa(int(port))))
assert.Equal(t, expected, ctx.Result)
},
),
Expand Down