diff --git a/.travis.yml b/.travis.yml index 274a88f..cfaa151 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ language: go go: - - "1.11.x" + - "1.18.x" - master before_install: - sudo service mysql stop diff --git a/go.mod b/go.mod index c57a21a..9ec8b19 100644 --- a/go.mod +++ b/go.mod @@ -1,38 +1,52 @@ module github.com/romanyx/polluter +go 1.18 + require ( - github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78 // indirect github.com/DATA-DOG/go-txdb v0.1.0 + github.com/go-redis/redis v6.14.0+incompatible + github.com/go-sql-driver/mysql v1.4.0 + github.com/jackc/pgx/v4 v4.17.2 + github.com/ory/dockertest v3.3.2+incompatible + github.com/pkg/errors v0.8.1 + github.com/romanyx/jwalk v1.0.0 + github.com/stretchr/testify v1.8.0 + gopkg.in/yaml.v2 v2.2.2 +) + +require ( + github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78 // indirect github.com/Microsoft/go-winio v0.4.11 // indirect github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 // indirect github.com/cenkalti/backoff v2.0.0+incompatible // indirect github.com/containerd/continuity v0.0.0-20181027224239-bea7585dbfac // indirect + github.com/davecgh/go-spew v1.1.1 // indirect github.com/docker/go-connections v0.4.0 // indirect - github.com/docker/go-units v0.3.3 // indirect - github.com/fsnotify/fsnotify v1.4.7 // indirect - github.com/go-redis/redis v6.14.0+incompatible - github.com/go-sql-driver/mysql v1.4.0 - github.com/golang/protobuf v1.2.0 // indirect - github.com/google/go-cmp v0.2.0 // indirect + github.com/docker/go-units v0.4.0 // indirect github.com/gotestyourself/gotestyourself v2.2.0+incompatible // indirect github.com/hpcloud/tail v1.0.0 // indirect - github.com/lib/pq v1.0.0 + github.com/jackc/chunkreader/v2 v2.0.1 // indirect + github.com/jackc/pgconn v1.13.0 // indirect + github.com/jackc/pgio v1.0.0 // indirect + github.com/jackc/pgpassfile v1.0.0 // indirect + github.com/jackc/pgproto3/v2 v2.3.1 // indirect + github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b // indirect + github.com/jackc/pgtype v1.12.0 // indirect + github.com/mailru/easyjson v0.0.0-20180823135443-60711f1a8329 // indirect github.com/onsi/ginkgo v1.6.0 // indirect github.com/onsi/gomega v1.4.1 // indirect github.com/opencontainers/go-digest v1.0.0-rc1 // indirect github.com/opencontainers/image-spec v1.0.1 // indirect - github.com/opencontainers/runc v0.1.1 // indirect - github.com/ory/dockertest v3.3.2+incompatible - github.com/pkg/errors v0.8.0 - github.com/romanyx/jwalk v1.0.0 - github.com/sirupsen/logrus v1.2.0 // indirect - github.com/stretchr/testify v1.2.2 - golang.org/x/net v0.0.0-20180826012351-8a410e7b638d // indirect - golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f // indirect - golang.org/x/text v0.3.0 // indirect + github.com/opencontainers/runc v1.1.4 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect + github.com/sirupsen/logrus v1.8.1 // indirect + golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa // indirect + golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2 // indirect + golang.org/x/sys v0.0.0-20211116061358-0a5406a5449c // indirect + golang.org/x/text v0.3.7 // indirect google.golang.org/appengine v1.1.0 // indirect gopkg.in/fsnotify.v1 v1.4.7 // indirect gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect - gopkg.in/yaml.v2 v2.2.1 + gopkg.in/yaml.v3 v3.0.1 // indirect gotest.tools v2.2.0+incompatible // indirect ) diff --git a/main_test.go b/main_test.go index 5d7c45d..e6931b8 100644 --- a/main_test.go +++ b/main_test.go @@ -13,13 +13,13 @@ import ( txdb "github.com/DATA-DOG/go-txdb" "github.com/go-redis/redis" mysqlD "github.com/go-sql-driver/mysql" - _ "github.com/lib/pq" + _ "github.com/jackc/pgx/v4/stdlib" "github.com/ory/dockertest" "github.com/pkg/errors" ) const ( - dockerStartWait = 60 * time.Second + dockerStartWait = 2 * 60 * time.Second ) var ( @@ -50,7 +50,7 @@ func TestMain(m *testing.M) { log.Fatalf("prepare pg with docker: %v\n", err) } - txdb.Register("pgsqltx", "postgres", fmt.Sprintf("password=test user=test dbname=test host=localhost port=%s sslmode=disable", p.Resource.GetPort("5432/tcp"))) + txdb.Register("pgsqltx", "pgx", fmt.Sprintf("postgres://test:test@localhost:%s/test?sslmode=disable", p.Resource.GetPort("5432/tcp"))) r, err := newRedis(pool) if err != nil { @@ -235,7 +235,7 @@ func newPG(pool *dockertest.Pool) (*pgDocker, error) { go func() { if err := pool.Retry(func() error { - db, err = sql.Open("postgres", fmt.Sprintf("user=test password=test dbname=test host=localhost port=%s sslmode=disable", res.GetPort("5432/tcp"))) + db, err = sql.Open("pgx", fmt.Sprintf("postgres://test:test@localhost:%s/test?sslmode=disable", res.GetPort("5432/tcp"))) if err != nil { return err } diff --git a/postgres_test.go b/postgres_test.go index ea49948..33d95b4 100644 --- a/postgres_test.go +++ b/postgres_test.go @@ -80,7 +80,7 @@ func Test_postgresEngine_exec(t *testing.T) { { name: "valid query", args: []command{ - command{ + { q: `INSERT INTO "users" ("id", "name") VALUES ($1, $2);`, args: []interface{}{ 1, @@ -92,7 +92,7 @@ func Test_postgresEngine_exec(t *testing.T) { { name: "invalid query", args: []command{ - command{ + { q: `INSERT INTO "roles" ("id", "name") VALUES ($1, $2);`, args: []interface{}{ 1,