You've already forked testing-go-code-with-postgres
mirror of
https://github.com/xorcare/testing-go-code-with-postgres.git
synced 2025-06-30 23:23:40 +02:00
Rename function for isolated database connection
Other ways to clean the database in tests will be added soon, so the tests are being moved to a separate file.
This commit is contained in:
@ -31,7 +31,7 @@ type TestingT interface {
|
||||
Failed() bool
|
||||
}
|
||||
|
||||
func New(t TestingT) *Postgres {
|
||||
func NewWithIsolatedDatabase(t TestingT) *Postgres {
|
||||
return newPostgres(t).cloneFromReference()
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,7 @@ func TestNewPostgres(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
// Arrange
|
||||
postgres := testingpg.New(t)
|
||||
postgres := testingpg.NewWithIsolatedDatabase(t)
|
||||
|
||||
ctx := context.Background()
|
||||
dbPool, err := pgxpool.New(ctx, postgres.URL())
|
||||
@ -45,7 +45,7 @@ func TestNewPostgres(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
// Arrange
|
||||
postgres := testingpg.New(t)
|
||||
postgres := testingpg.NewWithIsolatedDatabase(t)
|
||||
ctx := context.Background()
|
||||
|
||||
// Act
|
||||
@ -63,8 +63,8 @@ func TestNewPostgres(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
// Arrange
|
||||
postgres1 := testingpg.New(t)
|
||||
postgres2 := testingpg.New(t)
|
||||
postgres1 := testingpg.NewWithIsolatedDatabase(t)
|
||||
postgres2 := testingpg.NewWithIsolatedDatabase(t)
|
||||
|
||||
ctx := context.Background()
|
||||
|
||||
@ -82,8 +82,8 @@ func TestNewPostgres(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
// Arrange
|
||||
postgres1 := testingpg.New(t)
|
||||
postgres2 := testingpg.New(t)
|
||||
postgres1 := testingpg.NewWithIsolatedDatabase(t)
|
||||
postgres2 := testingpg.NewWithIsolatedDatabase(t)
|
||||
|
||||
// Act
|
||||
url1 := postgres1.URL()
|
||||
|
Reference in New Issue
Block a user