Skip to content

Commit

Permalink
Merge pull request #136 from dragonfriend0013/stat
Browse files Browse the repository at this point in the history
[+] add `PgxPoolIface.Stat()`, closes #135
  • Loading branch information
pashagolub authored May 3, 2023
2 parents a1e8f9f + 3867af3 commit ca4117b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,7 @@ func (p *pgxmockPool) Close() {
func (p *pgxmockPool) Acquire(context.Context) (*pgxpool.Conn, error) {
return nil, errors.New("pgpool.Acquire() method is not implemented")
}

func (p *pgxmockPool) Stat() *pgxpool.Stat {
return &pgxpool.Stat{}
}
11 changes: 11 additions & 0 deletions driver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,14 @@ func TestAcquire(t *testing.T) {
t.Error("expected error, but got nil")
}
}

func TestPoolStat(t *testing.T) {
mock, err := NewPool()
if err != nil {
t.Errorf("expected no error, but got: %s", err)
}
s := mock.Stat()
if s == nil {
t.Error("expected stat object, but got nil")
}
}
1 change: 1 addition & 0 deletions pgxmock.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ type PgxPoolIface interface {
pgx.Tx
Acquire(ctx context.Context) (*pgxpool.Conn, error)
Close()
Stat() *pgxpool.Stat
}

type pgxmock struct {
Expand Down

0 comments on commit ca4117b

Please sign in to comment.