Skip to content

Commit

Permalink
Add sqltest package with no-op DataSource definition
Browse files Browse the repository at this point in the history
  • Loading branch information
reductionista committed Nov 19, 2024
1 parent 9557da0 commit 1421b99
Showing 1 changed file with 65 additions and 0 deletions.
65 changes: 65 additions & 0 deletions pkg/sqltest/data_source.go
Original file line number Diff line number Diff line change
@@ -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
}

0 comments on commit 1421b99

Please sign in to comment.