Skip to content

Commit

Permalink
Add a minimal unimplemented DataSource mock that satisfies the interface
Browse files Browse the repository at this point in the history
  • Loading branch information
reductionista committed Nov 14, 2024
1 parent 9557da0 commit 537123e
Showing 1 changed file with 86 additions and 0 deletions.
86 changes: 86 additions & 0 deletions pkg/sqlutil/mocks/data_source.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
package mocks

import (
"context"
"database/sql"

"github.com/stretchr/testify/mock"

"github.com/jmoiron/sqlx"

"github.com/smartcontractkit/chainlink-common/pkg/sqlutil"
)

var _ sqlutil.DataSource = &DataSource{}

// DataSource is a mocked DataSource type. Note: this will only work to satisfy
// the interface, don't expect any of the usual Mock methods such as On() to
// work on it. This is to avoid depending on any particular version of mockery
// (which could be different in different repos making use of this)
type DataSource struct {
mock.Mock
}

// BindNamed provides a mock function with given fields: _a0, _a1
func (ds *DataSource) BindNamed(_a0 string, _a1 interface{}) (string, []interface{}, error) {
return "", nil, nil
}

// DriverName provides a mock function with given fields:
func (ds *DataSource) DriverName() string {
return ""
}

// ExecContext provides a mock function with given fields: ctx, query, args
func (ds *DataSource) ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error) {
return nil, nil
}

// GetContext provides a mock function with given fields: ctx, dest, query, args
func (ds *DataSource) GetContext(ctx context.Context, dest interface{}, query string, args ...interface{}) error {
return nil
}

// NamedExecContext provides a mock function with given fields: ctx, query, arg
func (ds *DataSource) NamedExecContext(ctx context.Context, query string, arg interface{}) (sql.Result, error) {
return nil, nil
}

// PrepareContext provides a mock function with given fields: ctx, query
func (ds *DataSource) PrepareContext(ctx context.Context, query string) (*sql.Stmt, error) {
return nil, nil
}

func (_m *DataSource) PrepareNamedContext(ctx context.Context, query string) (*sqlx.NamedStmt, error) {
return nil, nil
}

// QueryContext provides a mock function with given fields: ctx, query, args
func (ds *DataSource) QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error) {
return nil, nil
}

// QueryRowxContext provides a mock function with given fields: ctx, query, args
func (ds *DataSource) QueryRowxContext(ctx context.Context, query string, args ...interface{}) *sqlx.Row {
return nil
}

// QueryxContext provides a mock function with given fields: ctx, query, args
func (ds *DataSource) QueryxContext(ctx context.Context, query string, args ...interface{}) (*sqlx.Rows, error) {
return nil, nil
}

// Rebind provides a mock function with given fields: _a0
func (ds *DataSource) Rebind(_a0 string) string {
return ""
}

// SelectContext provides a mock function with given fields: ctx, dest, query, args
func (ds *DataSource) SelectContext(ctx context.Context, dest interface{}, query string, args ...interface{}) error {
return nil
}

// NewDataSource creates a new instance of DataSource.
func NewDataSource() *DataSource {
return &DataSource{}
}

0 comments on commit 537123e

Please sign in to comment.