postgre_sql

package
v0.3.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 29, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	DSN             string
	MaxConns        int32
	MinConns        int32
	MaxConnLifetime time.Duration
}

type IDB

type IDB interface {
	Exec(ctx context.Context, query string, args ...any) error
	Query(ctx context.Context, query string, args ...any) (Rows, error)
	QueryRow(ctx context.Context, query string, args ...any) Row

	Begin(ctx context.Context) (Tx, error)
	Ping(ctx context.Context) error
	Close()
	Raw() any
}

func NewPostgreSql

func NewPostgreSql(ctx context.Context, cfg Config) (IDB, error)

type MockIDB

type MockIDB struct {
	mock.Mock
}

MockIDB is an autogenerated mock type for the IDB type

func NewMockIDB

func NewMockIDB(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockIDB

NewMockIDB creates a new instance of MockIDB. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockIDB) Begin

func (_m *MockIDB) Begin(ctx context.Context) (Tx, error)

Begin provides a mock function with given fields: ctx

func (*MockIDB) Close

func (_m *MockIDB) Close()

Close provides a mock function with no fields

func (*MockIDB) EXPECT

func (_m *MockIDB) EXPECT() *MockIDB_Expecter

func (*MockIDB) Exec

func (_m *MockIDB) Exec(ctx context.Context, query string, args ...any) error

Exec provides a mock function with given fields: ctx, query, args

func (*MockIDB) Ping

func (_m *MockIDB) Ping(ctx context.Context) error

Ping provides a mock function with given fields: ctx

func (*MockIDB) Query

func (_m *MockIDB) Query(ctx context.Context, query string, args ...any) (Rows, error)

Query provides a mock function with given fields: ctx, query, args

func (*MockIDB) QueryRow

func (_m *MockIDB) QueryRow(ctx context.Context, query string, args ...any) Row

QueryRow provides a mock function with given fields: ctx, query, args

func (*MockIDB) Raw added in v0.2.5

func (_m *MockIDB) Raw() any

Raw provides a mock function with no fields

type MockIDB_Begin_Call

type MockIDB_Begin_Call struct {
	*mock.Call
}

MockIDB_Begin_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Begin'

func (*MockIDB_Begin_Call) Return

func (_c *MockIDB_Begin_Call) Return(_a0 Tx, _a1 error) *MockIDB_Begin_Call

func (*MockIDB_Begin_Call) Run

func (_c *MockIDB_Begin_Call) Run(run func(ctx context.Context)) *MockIDB_Begin_Call

func (*MockIDB_Begin_Call) RunAndReturn

func (_c *MockIDB_Begin_Call) RunAndReturn(run func(context.Context) (Tx, error)) *MockIDB_Begin_Call

type MockIDB_Close_Call

type MockIDB_Close_Call struct {
	*mock.Call
}

MockIDB_Close_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Close'

func (*MockIDB_Close_Call) Return

func (_c *MockIDB_Close_Call) Return() *MockIDB_Close_Call

func (*MockIDB_Close_Call) Run

func (_c *MockIDB_Close_Call) Run(run func()) *MockIDB_Close_Call

func (*MockIDB_Close_Call) RunAndReturn

func (_c *MockIDB_Close_Call) RunAndReturn(run func()) *MockIDB_Close_Call

type MockIDB_Exec_Call

type MockIDB_Exec_Call struct {
	*mock.Call
}

MockIDB_Exec_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Exec'

func (*MockIDB_Exec_Call) Return

func (_c *MockIDB_Exec_Call) Return(_a0 error) *MockIDB_Exec_Call

func (*MockIDB_Exec_Call) Run

func (_c *MockIDB_Exec_Call) Run(run func(ctx context.Context, query string, args ...any)) *MockIDB_Exec_Call

func (*MockIDB_Exec_Call) RunAndReturn

func (_c *MockIDB_Exec_Call) RunAndReturn(run func(context.Context, string, ...any) error) *MockIDB_Exec_Call

type MockIDB_Expecter

type MockIDB_Expecter struct {
	// contains filtered or unexported fields
}

func (*MockIDB_Expecter) Begin

func (_e *MockIDB_Expecter) Begin(ctx interface{}) *MockIDB_Begin_Call

Begin is a helper method to define mock.On call

  • ctx context.Context

func (*MockIDB_Expecter) Close

func (_e *MockIDB_Expecter) Close() *MockIDB_Close_Call

Close is a helper method to define mock.On call

func (*MockIDB_Expecter) Exec

func (_e *MockIDB_Expecter) Exec(ctx interface{}, query interface{}, args ...interface{}) *MockIDB_Exec_Call

Exec is a helper method to define mock.On call

  • ctx context.Context
  • query string
  • args ...any

func (*MockIDB_Expecter) Ping

func (_e *MockIDB_Expecter) Ping(ctx interface{}) *MockIDB_Ping_Call

Ping is a helper method to define mock.On call

  • ctx context.Context

func (*MockIDB_Expecter) Query

func (_e *MockIDB_Expecter) Query(ctx interface{}, query interface{}, args ...interface{}) *MockIDB_Query_Call

Query is a helper method to define mock.On call

  • ctx context.Context
  • query string
  • args ...any

func (*MockIDB_Expecter) QueryRow

func (_e *MockIDB_Expecter) QueryRow(ctx interface{}, query interface{}, args ...interface{}) *MockIDB_QueryRow_Call

QueryRow is a helper method to define mock.On call

  • ctx context.Context
  • query string
  • args ...any

func (*MockIDB_Expecter) Raw added in v0.2.5

Raw is a helper method to define mock.On call

type MockIDB_Ping_Call

type MockIDB_Ping_Call struct {
	*mock.Call
}

MockIDB_Ping_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Ping'

func (*MockIDB_Ping_Call) Return

func (_c *MockIDB_Ping_Call) Return(_a0 error) *MockIDB_Ping_Call

func (*MockIDB_Ping_Call) Run

func (_c *MockIDB_Ping_Call) Run(run func(ctx context.Context)) *MockIDB_Ping_Call

func (*MockIDB_Ping_Call) RunAndReturn

func (_c *MockIDB_Ping_Call) RunAndReturn(run func(context.Context) error) *MockIDB_Ping_Call

type MockIDB_QueryRow_Call

type MockIDB_QueryRow_Call struct {
	*mock.Call
}

MockIDB_QueryRow_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'QueryRow'

func (*MockIDB_QueryRow_Call) Return

func (*MockIDB_QueryRow_Call) Run

func (_c *MockIDB_QueryRow_Call) Run(run func(ctx context.Context, query string, args ...any)) *MockIDB_QueryRow_Call

func (*MockIDB_QueryRow_Call) RunAndReturn

func (_c *MockIDB_QueryRow_Call) RunAndReturn(run func(context.Context, string, ...any) Row) *MockIDB_QueryRow_Call

type MockIDB_Query_Call

type MockIDB_Query_Call struct {
	*mock.Call
}

MockIDB_Query_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Query'

func (*MockIDB_Query_Call) Return

func (_c *MockIDB_Query_Call) Return(_a0 Rows, _a1 error) *MockIDB_Query_Call

func (*MockIDB_Query_Call) Run

func (_c *MockIDB_Query_Call) Run(run func(ctx context.Context, query string, args ...any)) *MockIDB_Query_Call

func (*MockIDB_Query_Call) RunAndReturn

func (_c *MockIDB_Query_Call) RunAndReturn(run func(context.Context, string, ...any) (Rows, error)) *MockIDB_Query_Call

type MockIDB_Raw_Call added in v0.2.5

type MockIDB_Raw_Call struct {
	*mock.Call
}

MockIDB_Raw_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Raw'

func (*MockIDB_Raw_Call) Return added in v0.2.5

func (_c *MockIDB_Raw_Call) Return(_a0 any) *MockIDB_Raw_Call

func (*MockIDB_Raw_Call) Run added in v0.2.5

func (_c *MockIDB_Raw_Call) Run(run func()) *MockIDB_Raw_Call

func (*MockIDB_Raw_Call) RunAndReturn added in v0.2.5

func (_c *MockIDB_Raw_Call) RunAndReturn(run func() any) *MockIDB_Raw_Call

type Row

type Row interface {
	Scan(dest ...any) error
}

type Rows

type Rows interface {
	Next() bool
	Scan(dest ...any) error
	Close()
	Err() error
}

type Tx

type Tx interface {
	Exec(ctx context.Context, query string, args ...any) error
	Query(ctx context.Context, query string, args ...any) (Rows, error)
	QueryRow(ctx context.Context, query string, args ...any) Row

	Commit(ctx context.Context) error
	Rollback(ctx context.Context) error
	Raw() any
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL