0815cb35fb
Basic Lint Checks * basic
40 lines
752 B
Go
40 lines
752 B
Go
package repository_test
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"queryorchestration/internal/database/repository"
|
|
|
|
"github.com/jackc/pgx/v5"
|
|
"github.com/pashagolub/pgxmock/v3"
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestQueriesNew(t *testing.T) {
|
|
pool, err := pgxmock.NewPool()
|
|
require.NoError(t, err)
|
|
|
|
queries := repository.New(pool)
|
|
assert.NotNil(t, queries)
|
|
}
|
|
|
|
func TestQueriesWithTx(t *testing.T) {
|
|
ctx := context.Background()
|
|
|
|
pool, err := pgxmock.NewPool()
|
|
require.NoError(t, err)
|
|
|
|
queries := repository.New(pool)
|
|
assert.NotNil(t, queries)
|
|
|
|
pool.ExpectBeginTx(pgx.TxOptions{})
|
|
|
|
tx, err := pool.Begin(ctx)
|
|
assert.NoError(t, err)
|
|
|
|
txQueries := queries.WithTx(tx)
|
|
assert.NotNil(t, txQueries)
|
|
}
|