From f49836630bccf3e043142bb31e4bb6109130f622 Mon Sep 17 00:00:00 2001 From: Pavlo Golub Date: Mon, 12 Feb 2024 18:49:30 +0100 Subject: [PATCH] make linter happy --- internal/pgengine/access_test.go | 2 +- internal/pgengine/bootstrap.go | 4 ++-- internal/pgengine/migration.go | 2 +- internal/scheduler/chain_test.go | 10 +++++----- internal/scheduler/interval_chain_test.go | 6 +++--- internal/tasks/mail_test.go | 2 +- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/internal/pgengine/access_test.go b/internal/pgengine/access_test.go index 683f7db..c4c64a5 100644 --- a/internal/pgengine/access_test.go +++ b/internal/pgengine/access_test.go @@ -104,7 +104,7 @@ func TestLogChainElementExecution(t *testing.T) { pge := pgengine.NewDB(mockPool, "pgengine_unit_test") defer mockPool.Close() - t.Run("Check LogChainElementExecution if sql fails", func(t *testing.T) { + t.Run("Check LogChainElementExecution if sql fails", func(*testing.T) { mockPool.ExpectExec("INSERT INTO .*execution_log").WithArgs( pgxmock.AnyArg(), pgxmock.AnyArg(), pgxmock.AnyArg(), pgxmock.AnyArg(), pgxmock.AnyArg(), pgxmock.AnyArg(), pgxmock.AnyArg(), pgxmock.AnyArg(), pgxmock.AnyArg(), pgxmock.AnyArg(), pgxmock.AnyArg()). diff --git a/internal/pgengine/bootstrap.go b/internal/pgengine/bootstrap.go index f0449f1..c0ad942 100644 --- a/internal/pgengine/bootstrap.go +++ b/internal/pgengine/bootstrap.go @@ -98,7 +98,7 @@ func New(ctx context.Context, cmdOpts config.CmdOptions, logger log.LoggerHooker config := pge.getPgxConnConfig() if err = retry.Do(connctx, backoff, func(ctx context.Context) error { - if pge.ConfigDb, err = pgxpool.NewWithConfig(connctx, config); err == nil { + if pge.ConfigDb, err = pgxpool.NewWithConfig(ctx, config); err == nil { err = pge.ConfigDb.Ping(connctx) } if err != nil { @@ -161,7 +161,7 @@ func (pge *PgEngine) getPgxConnConfig() *pgxpool.Config { // and another connection for LogHook.send() connConfig.MaxConns = int32(pge.Resource.CronWorkers) + int32(pge.Resource.IntervalWorkers) + 3 connConfig.ConnConfig.RuntimeParams["application_name"] = "pg_timetable" - connConfig.ConnConfig.OnNotice = func(c *pgconn.PgConn, n *pgconn.Notice) { + connConfig.ConnConfig.OnNotice = func(_ *pgconn.PgConn, n *pgconn.Notice) { pge.l.WithField("severity", n.Severity).WithField("notice", n.Message).Info("Notice received") } connConfig.AfterConnect = func(ctx context.Context, pgconn *pgx.Conn) (err error) { diff --git a/internal/pgengine/migration.go b/internal/pgengine/migration.go index 6394eb6..b1852d6 100644 --- a/internal/pgengine/migration.go +++ b/internal/pgengine/migration.go @@ -58,7 +58,7 @@ var Migrations func() migrator.Option = func() migrator.Option { return migrator.Migrations( &migrator.Migration{ Name: "00259 Restart migrations for v4", - Func: func(ctx context.Context, tx pgx.Tx) error { + Func: func(context.Context, pgx.Tx) error { // "migrations" table will be created automatically return nil }, diff --git a/internal/scheduler/chain_test.go b/internal/scheduler/chain_test.go index bbe654c..a666fc7 100644 --- a/internal/scheduler/chain_test.go +++ b/internal/scheduler/chain_test.go @@ -63,14 +63,14 @@ func TestChainWorker(t *testing.T) { sch := New(pge, log.Init(config.LoggingOpts{LogLevel: "error"})) chains := make(chan Chain, 16) - t.Run("Check chainWorker if context cancelled", func(t *testing.T) { + t.Run("Check chainWorker if context cancelled", func(*testing.T) { ctx, cancel := context.WithCancel(context.Background()) cancel() chains <- Chain{} sch.chainWorker(ctx, chains) }) - t.Run("Check chainWorker if everything fine", func(t *testing.T) { + t.Run("Check chainWorker if everything fine", func(*testing.T) { ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) defer cancel() mock.ExpectQuery("SELECT count").WillReturnError(pgx.ErrNoRows) @@ -82,7 +82,7 @@ func TestChainWorker(t *testing.T) { sch.chainWorker(ctx, chains) }) - t.Run("Check chainWorker if cannot proceed with chain execution", func(t *testing.T) { + t.Run("Check chainWorker if cannot proceed with chain execution", func(*testing.T) { ctx, cancel := context.WithTimeout(context.Background(), pgengine.WaitTime+2) defer cancel() mock.ExpectQuery("SELECT count").WillReturnError(errors.New("expected")) @@ -130,13 +130,13 @@ func TestExecuteOnErrorHandler(t *testing.T) { assert.NoError(t, mock.ExpectationsWereMet()) }) - t.Run("check error handler if context cancelled", func(t *testing.T) { + t.Run("check error handler if context cancelled", func(*testing.T) { ctx, cancel := context.WithCancel(context.Background()) cancel() sch.executeOnErrorHandler(ctx, c) }) - t.Run("check error handler if error", func(t *testing.T) { + t.Run("check error handler if error", func(*testing.T) { mock.ExpectExec("FOO").WillReturnError(errors.New("Syntax error near FOO")) sch.executeOnErrorHandler(context.Background(), c) }) diff --git a/internal/scheduler/interval_chain_test.go b/internal/scheduler/interval_chain_test.go index e3e6ceb..c182272 100644 --- a/internal/scheduler/interval_chain_test.go +++ b/internal/scheduler/interval_chain_test.go @@ -25,21 +25,21 @@ func TestIntervalChain(t *testing.T) { sch.intervalChains[ichain.ChainID] = ichain assert.True(t, sch.isValid(ichain)) - t.Run("Check reschedule if self destructive", func(t *testing.T) { + t.Run("Check reschedule if self destructive", func(*testing.T) { mock.ExpectExec("INSERT INTO timetable\\.log").WillReturnResult(pgxmock.NewResult("EXECUTE", 1)) mock.ExpectExec("DELETE").WillReturnResult(pgxmock.NewResult("EXECUTE", 1)) ichain.SelfDestruct = true sch.reschedule(context.Background(), ichain) }) - t.Run("Check reschedule if context cancelled", func(t *testing.T) { + t.Run("Check reschedule if context cancelled", func(*testing.T) { ctx, cancel := context.WithCancel(context.Background()) cancel() ichain.SelfDestruct = false sch.reschedule(ctx, ichain) }) - t.Run("Check reschedule if everything fine", func(t *testing.T) { + t.Run("Check reschedule if everything fine", func(*testing.T) { ichain.Interval = 1 sch.reschedule(context.Background(), ichain) }) diff --git a/internal/tasks/mail_test.go b/internal/tasks/mail_test.go index 53d1ee7..06c6d7f 100644 --- a/internal/tasks/mail_test.go +++ b/internal/tasks/mail_test.go @@ -18,7 +18,7 @@ func (d *fakeDialer) DialAndSend(context.Context, ...*gomail.Message) error { func TestTaskSendMail(t *testing.T) { assert.NotNil(t, NewDialer("", 0, "", ""), "Default dialer should be created") - NewDialer = func(host string, port int, username, password string) Dialer { + NewDialer = func(string, int, string, string) Dialer { return &fakeDialer{} } assert.NoError(t, SendMail(context.Background(), EmailConn{