mirror of
https://github.com/grafana/grafana.git
synced 2025-07-31 03:42:39 +08:00
Postgres: Improve invalid port specifier error during health check (#105536)
normalize error message in postgres invalid port specifier error
This commit is contained in:
@ -2,6 +2,7 @@ package sqleng
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"net"
|
||||
"testing"
|
||||
|
||||
@ -48,6 +49,15 @@ func TestErrToHealthCheckResult(t *testing.T) {
|
||||
JSONDetails: []byte(`{"errorDetailsLink":"https://grafana.com/docs/grafana/latest/datasources/postgres","verboseMessage":"internal server error"}`),
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "invalid port specifier error",
|
||||
err: fmt.Errorf("%w %q: %w", ErrInvalidPortSpecified, `"foo.bar.co"`, errors.New(`strconv.Atoi: parsing "foo.bar.co": invalid syntax`)),
|
||||
want: &backend.CheckHealthResult{
|
||||
Status: backend.HealthStatusError,
|
||||
Message: "Connection string error: invalid port in host specifier",
|
||||
JSONDetails: []byte(`{"errorDetailsLink":"https://grafana.com/docs/grafana/latest/datasources/postgres","verboseMessage":"invalid port in host specifier \"\\\"foo.bar.co\\\"\": strconv.Atoi: parsing \"foo.bar.co\": invalid syntax"}`),
|
||||
},
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
|
Reference in New Issue
Block a user