Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Steinhardt <psteinhardt@gitlab.com>2021-09-16 15:09:58 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2021-09-20 17:22:32 +0300
commit821df9c3f9a67d147f8603887559e24944d1afe3 (patch)
treeae8da5d9ff55bd61ac6de73325a02bb41cc73967
parentd50a4db76b5926a6ab914d882e3f3a161f91d625 (diff)
glsql: Start to use new `net.ErrClosed` error type
With Go 1.16, it is now possible to detect network failures via the new `net.ErrClosed` error type. Adapt the glsql testing package to use this type instead of doing a string comparison.
-rw-r--r--internal/praefect/datastore/glsql/testing.go7
1 files changed, 2 insertions, 5 deletions
diff --git a/internal/praefect/datastore/glsql/testing.go b/internal/praefect/datastore/glsql/testing.go
index d1cc2806e..bb9430b1f 100644
--- a/internal/praefect/datastore/glsql/testing.go
+++ b/internal/praefect/datastore/glsql/testing.go
@@ -3,6 +3,7 @@ package glsql
import (
"database/sql"
"errors"
+ "net"
"os"
"os/exec"
"strconv"
@@ -268,11 +269,7 @@ func initPraefectTestDB(t testing.TB, database string) *sql.DB {
dbCfg.DBName = database
praefectTestDB := requireSQLOpen(t, dbCfg, false)
t.Cleanup(func() {
- // This could should replace current implementation after drop support of Go 1.15
- //if err := praefectTestDB.Close(); !errors.Is(err, net.ErrClosed) {
- // require.NoErrorf(t, err, "release connection to the %q database", dbCfg.DBName)
- //}
- if err := praefectTestDB.Close(); err != nil && !strings.Contains(err.Error(), "use of closed network connection") {
+ if err := praefectTestDB.Close(); !errors.Is(err, net.ErrClosed) {
require.NoErrorf(t, err, "release connection to the %q database", dbCfg.DBName)
}
})