From 1421b990f9c5c0ce0c074dd0289b6dc02171282f Mon Sep 17 00:00:00 2001 From: Domino Valdano <2644901+reductionista@users.noreply.github.com> Date: Tue, 5 Nov 2024 14:49:36 -0800 Subject: [PATCH 1/2] Add sqltest package with no-op DataSource definition --- pkg/sqltest/data_source.go | 65 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 pkg/sqltest/data_source.go diff --git a/pkg/sqltest/data_source.go b/pkg/sqltest/data_source.go new file mode 100644 index 000000000..32413e52c --- /dev/null +++ b/pkg/sqltest/data_source.go @@ -0,0 +1,65 @@ +package sqltest + +import ( + "context" + "database/sql" + + "github.com/jmoiron/sqlx" + + "github.com/smartcontractkit/chainlink-common/pkg/sqlutil" +) + +// NewNoOpDataSource returns an empty DataSource type which will satisfy the interface +func NewNoOpDataSource() sqlutil.DataSource { + return &noOpDataSource{} +} + +type noOpDataSource struct{} + +func (ds *noOpDataSource) BindNamed(s string, _ interface{}) (string, []interface{}, error) { + return "", nil, nil +} + +func (ds *noOpDataSource) DriverName() string { + return "" +} + +func (ds *noOpDataSource) ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error) { + return nil, nil +} + +func (ds *noOpDataSource) GetContext(ctx context.Context, dest interface{}, query string, args ...interface{}) error { + return nil +} + +func (ds *noOpDataSource) NamedExecContext(ctx context.Context, query string, arg interface{}) (sql.Result, error) { + return nil, nil +} + +func (ds *noOpDataSource) PrepareContext(ctx context.Context, query string) (*sql.Stmt, error) { + return nil, nil +} + +func (_m *noOpDataSource) PrepareNamedContext(ctx context.Context, query string) (*sqlx.NamedStmt, error) { + return nil, nil +} + +func (ds *noOpDataSource) QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error) { + return nil, nil +} + +func (ds *noOpDataSource) QueryRowxContext(ctx context.Context, query string, args ...interface{}) *sqlx.Row { + return nil +} + +func (ds *noOpDataSource) QueryxContext(ctx context.Context, query string, args ...interface{}) (*sqlx.Rows, error) { + return nil, nil +} + +func (ds *noOpDataSource) Rebind(s string) string { + return "" +} + +func (ds *noOpDataSource) SelectContext(ctx context.Context, dest interface{}, query string, args ...interface{}) error { + return nil +} From 069f39af0eb8796b35ceec142b66b8f42fd25cbf Mon Sep 17 00:00:00 2001 From: Domino Valdano <2644901+reductionista@users.noreply.github.com> Date: Tue, 19 Nov 2024 13:07:53 -0800 Subject: [PATCH 2/2] sqltest -> sqlutil/sqltest --- pkg/{ => sqlutil}/sqltest/data_source.go | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename pkg/{ => sqlutil}/sqltest/data_source.go (100%) diff --git a/pkg/sqltest/data_source.go b/pkg/sqlutil/sqltest/data_source.go similarity index 100% rename from pkg/sqltest/data_source.go rename to pkg/sqlutil/sqltest/data_source.go