-
Notifications
You must be signed in to change notification settings - Fork 136
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bbaa41c
commit 6f90805
Showing
4 changed files
with
184 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package nucleusdb | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/jackc/pgx/v5" | ||
pgconn "github.com/jackc/pgx/v5/pgconn" | ||
mock "github.com/stretchr/testify/mock" | ||
) | ||
|
||
// MockTx is a mock type for the Tx interface | ||
type MockTx struct { | ||
mock.Mock | ||
} | ||
|
||
func (m *MockTx) Begin(ctx context.Context) (pgx.Tx, error) { | ||
args := m.Called(ctx) | ||
return args.Get(0).(pgx.Tx), args.Error(1) | ||
} | ||
|
||
func (m *MockTx) Commit(ctx context.Context) error { | ||
args := m.Called(ctx) | ||
return args.Error(0) | ||
} | ||
|
||
func (m *MockTx) Rollback(ctx context.Context) error { | ||
args := m.Called(ctx) | ||
return args.Error(0) | ||
} | ||
|
||
func (m *MockTx) CopyFrom(ctx context.Context, tableName pgx.Identifier, columnNames []string, rowSrc pgx.CopyFromSource) (int64, error) { | ||
args := m.Called(ctx, tableName, columnNames, rowSrc) | ||
return args.Get(0).(int64), args.Error(1) | ||
} | ||
|
||
func (m *MockTx) SendBatch(ctx context.Context, b *pgx.Batch) pgx.BatchResults { | ||
args := m.Called(ctx, b) | ||
return args.Get(0).(pgx.BatchResults) | ||
} | ||
|
||
func (m *MockTx) LargeObjects() pgx.LargeObjects { | ||
args := m.Called() | ||
return args.Get(0).(pgx.LargeObjects) | ||
} | ||
|
||
func (m *MockTx) Prepare(ctx context.Context, name, sql string) (*pgconn.StatementDescription, error) { | ||
args := m.Called(ctx, name, sql) | ||
return args.Get(0).(*pgconn.StatementDescription), args.Error(1) | ||
} | ||
|
||
func (m *MockTx) Exec(ctx context.Context, sql string, arguments ...any) (pgconn.CommandTag, error) { | ||
args := m.Called(ctx, sql, arguments) | ||
return args.Get(0).(pgconn.CommandTag), args.Error(1) | ||
} | ||
|
||
func (m *MockTx) Query(ctx context.Context, sql string, args ...any) (pgx.Rows, error) { | ||
callArgs := m.Called(ctx, sql, args) | ||
return callArgs.Get(0).(pgx.Rows), callArgs.Error(1) | ||
} | ||
|
||
func (m *MockTx) QueryRow(ctx context.Context, sql string, args ...any) pgx.Row { | ||
callArgs := m.Called(ctx, sql, args) | ||
return callArgs.Get(0).(pgx.Row) | ||
} | ||
|
||
func (m *MockTx) Conn() *pgx.Conn { | ||
args := m.Called() | ||
return args.Get(0).(*pgx.Conn) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters