Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
One of these was causing golint errors, the other failing due to txdb not being registered.
  • Loading branch information
reductionista committed Nov 26, 2024
1 parent ceaa028 commit ae7772c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 20 deletions.
28 changes: 14 additions & 14 deletions core/services/chainlink/config_database_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,24 +29,24 @@ URL = "postgresql://doesnotexist:justtopassvalidationtests@localhost:5432/chainl
assert.Nil(t, backup.URL())

db := cfg.Database()
assert.Equal(t, db.DefaultIdleInTxSessionTimeout(), 1*time.Minute)
assert.Equal(t, db.DefaultLockTimeout(), 1*time.Hour)
assert.Equal(t, db.DefaultQueryTimeout(), 1*time.Second)
assert.Equal(t, db.LogSQL(), true)
assert.Equal(t, db.MaxIdleConns(), 7)
assert.Equal(t, db.MaxOpenConns(), 13)
assert.Equal(t, db.MigrateDatabase(), true)
assert.Equal(t, db.Dialect(), pgcommon.Postgres)
assert.Equal(t, 1*time.Minute, db.DefaultIdleInTxSessionTimeout())
assert.Equal(t, 1*time.Hour, db.DefaultLockTimeout())
assert.Equal(t, 1*time.Second, db.DefaultQueryTimeout())
assert.Equal(t, true, db.LogSQL())
assert.Equal(t, 7, db.MaxIdleConns())
assert.Equal(t, 13, db.MaxOpenConns())
assert.Equal(t, true, db.MigrateDatabase())
assert.Equal(t, pgcommon.Postgres, db.Dialect())
url := db.URL()
assert.NotEqual(t, url.String(), "")

lock := db.Lock()
assert.Equal(t, lock.LockingMode(), "none")
assert.Equal(t, lock.LeaseDuration(), 1*time.Minute)
assert.Equal(t, lock.LeaseRefreshInterval(), 1*time.Second)
assert.Equal(t, "none", lock.LockingMode())
assert.Equal(t, 1*time.Minute, lock.LeaseDuration())
assert.Equal(t, 1*time.Second, lock.LeaseRefreshInterval())

l := db.Listener()
assert.Equal(t, l.MaxReconnectDuration(), 1*time.Minute)
assert.Equal(t, l.MinReconnectInterval(), 5*time.Minute)
assert.Equal(t, l.FallbackPollInterval(), 2*time.Minute)
assert.Equal(t, 1*time.Minute, l.MaxReconnectDuration())
assert.Equal(t, 5*time.Minute, l.MinReconnectInterval())
assert.Equal(t, 2*time.Minute, l.FallbackPollInterval())
}
10 changes: 4 additions & 6 deletions core/services/pg/connection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@ import (
"testing"
"time"

"github.com/google/uuid"
_ "github.com/jackc/pgx/v4/stdlib"
"github.com/jmoiron/sqlx"
"github.com/pkg/errors"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

pgcommon "github.com/smartcontractkit/chainlink-common/pkg/pg"
"github.com/smartcontractkit/chainlink-common/pkg/utils/tests"

"github.com/smartcontractkit/chainlink/v2/core/internal/testutils/pgtest"
)

var _ Getter = &mockGetter{}
Expand Down Expand Up @@ -67,11 +66,10 @@ func Test_checkVersion(t *testing.T) {

func Test_disallowReplica(t *testing.T) {
tests.SkipShortDB(t)
db, err := sqlx.Open(string(pgcommon.TransactionWrappedPostgres), uuid.New().String())
require.NoError(t, err)
db := pgtest.NewSqlxDB(t)
t.Cleanup(func() { require.NoError(t, db.Close()) })

_, err = db.Exec("SET session_replication_role= 'origin'")
_, err := db.Exec("SET session_replication_role= 'origin'")
require.NoError(t, err)
err = disallowReplica(db)
require.NoError(t, err)
Expand Down

0 comments on commit ae7772c

Please sign in to comment.