Skip to content

Commit

Permalink
[+] make sure pgxmockPool.Config() initializes ConnConfig (#223)
Browse files Browse the repository at this point in the history
  • Loading branch information
pashagolub authored Jan 9, 2025
1 parent 78fb3c5 commit d0c4457
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func (p *pgxmockPool) Acquire(context.Context) (*pgxpool.Conn, error) {
}

func (p *pgxmockPool) Config() *pgxpool.Config {
return &pgxpool.Config{}
return &pgxpool.Config{ConnConfig: &pgx.ConnConfig{}}
}

// AsConn is similar to Acquire but returns proper mocking interface
Expand Down
25 changes: 25 additions & 0 deletions driver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,28 @@ func TestPoolStat(t *testing.T) {
t.Error("expected stat object, but got nil")
}
}

func TestPoolConfig(t *testing.T) {
mock, err := NewPool()
if err != nil {
t.Fatalf("expected no error, but got: %s", err)
}
c := mock.Config()
if c == nil {
t.Fatal("expected config object, but got nil")
}
if c.ConnConfig == nil {
t.Fatal("expected conn config object, but got nil")
}
}

func TestConnConfig(t *testing.T) {
mock, err := NewConn()
if err != nil {
t.Fatalf("expected no error, but got: %s", err)
}
c := mock.Config()
if c == nil {
t.Fatal("expected config object, but got nil")
}
}

0 comments on commit d0c4457

Please sign in to comment.