7ce7c9df4d
Feature/ecr * nosave * repo * awscli * unzip * ignore * moreram * 14k * ref * deployment * 12k * uselocal * go * dockercomd * reorder * iamgename * installs * tart * cli * clideps * y * dockerce * nodock * multi * rmecr * dev
39 lines
733 B
Go
39 lines
733 B
Go
package repository_test
|
|
|
|
import (
|
|
"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 := t.Context()
|
|
|
|
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)
|
|
require.NoError(t, err)
|
|
|
|
txQueries := queries.WithTx(tx)
|
|
assert.NotNil(t, txQueries)
|
|
}
|