Skip to content

Commit

Permalink
make linter happy
Browse files Browse the repository at this point in the history
  • Loading branch information
pashagolub committed Feb 12, 2024
1 parent ccf82df commit f498366
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion internal/pgengine/access_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()).
Expand Down
4 changes: 2 additions & 2 deletions internal/pgengine/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion internal/pgengine/migration.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
},
Expand Down
10 changes: 5 additions & 5 deletions internal/scheduler/chain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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"))
Expand Down Expand Up @@ -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)
})
Expand Down
6 changes: 3 additions & 3 deletions internal/scheduler/interval_chain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
Expand Down
2 changes: 1 addition & 1 deletion internal/tasks/mail_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down

0 comments on commit f498366

Please sign in to comment.