Documentation ¶
Index ¶
- Variables
- func DialTCP(network, addr string) (net.Conn, error)
- func IsPointer(item reflect.Type) bool
- func IsSlice(item reflect.Type) bool
- func IsStruct(item reflect.Type) bool
- func QueryJSON(backend Backender, query string, args ...interface{}) (string, error)
- func QueryJSONRow(backend Backender, query string, args ...interface{}) (string, error)
- func QueryStruct(backend Backender, result interface{}, query string, args ...interface{}) error
- func QueryStructRow(backend Backender, result interface{}, query string, args ...interface{}) error
- func QueryValues(backend Backender, query *Query, result ...interface{}) error
- func QueryWriteCSV(w io.Writer, options CSVOptions, backend Backender, query string, ...) error
- func SetValue(dest reflect.Value, src *interface{}) error
- type Backender
- type CSVOptions
- type DBer
- type DialFunc
- type MethodsRun
- type Mocker
- type Query
- type RowsScanner
- type Scanner
Constants ¶
This section is empty.
Variables ¶
var ErrNoMethods = errors.New("No methods found to have been run")
ErrNoMethods is an error for when no methods are left to verify.
var ErrQueryIsNil = errors.New("invalid query")
ErrQueryIsNil occurs when the provided query is invalid.
var ErrRowScannerInvalidData = errors.New("data must be a ptr to a struct")
ErrRowScannerInvalidData occurs when the provided data is not a pointer to a struct.
var ErrRowsScannerInvalidData = errors.New("data must be a slice of structs")
ErrRowsScannerInvalidData occurs when the provided data is not a slice of type struct.
Functions ¶
func DialTCP ¶
DialTCP is a helper function that will dial a TCP port and set a 2 minute time period
func QueryJSONRow ¶
QueryJSONRow runs a query against the provided Backender and returns the JSON result
func QueryStruct ¶
QueryStruct runs a query against the provided Backender and populates the provided result
func QueryStructRow ¶
QueryStructRow runs a query against the provided Backender and populates the provided result
func QueryValues ¶
QueryValues runs a query against the provided Backender and populates result values
func QueryWriteCSV ¶
func QueryWriteCSV(w io.Writer, options CSVOptions, backend Backender, query string, args ...interface{}) error
QueryWriteCSV runs a query against the provided Backender and saves the response to the specified file in CSV format
Types ¶
type Backender ¶
type Backender interface { Query(query string, args ...interface{}) (RowsScanner, error) QueryRow(query string, args ...interface{}) Scanner }
Backender is the db interface needed by onedb to enable QueryStruct and QueryJSON capability
type CSVOptions ¶
type CSVOptions struct {
DateOnly bool
}
CSVOptions contains specifications for how text should be formatted in a CSV file
type DBer ¶
type DBer interface { QueryValues(query *Query, result ...interface{}) error QueryJSON(query string, args ...interface{}) (string, error) QueryJSONRow(query string, args ...interface{}) (string, error) QueryStruct(result interface{}, query string, args ...interface{}) error QueryStructRow(result interface{}, query string, args ...interface{}) error QueryWriteCSV(w io.Writer, options CSVOptions, query string, args ...interface{}) error }
DBer is the added interface that onedb can enable for database querying
type DialFunc ¶
DialFunc is the shape of the function used to dial a TCP connection
func NewMockDialer ¶
NewMockDialer returns a onedb.DialFunc for testing purposes
type MethodsRun ¶
type MethodsRun struct { MethodName string Arguments []interface{} }
MethodsRun contains the name of the method run and a slice of arguments
type Mocker ¶
type Mocker interface { DBer Query(query string, args ...interface{}) (RowsScanner, error) QueryRow(query string, args ...interface{}) Scanner QueriesRun() []MethodsRun SaveMethodCall(name string, arguments []interface{}) VerifyNextCommand(t *testing.T, name string, expected ...interface{}) }
Mocker is a fake database that can be used in place of a pgx or sql lib database for testing
type Query ¶
type Query struct { Query string Args []interface{} }
Query is a generic struct that houses a query string and arguments used to construct a query
type RowsScanner ¶
type RowsScanner interface { Close() error Columns() ([]string, error) Next() bool Err() error Scanner }
RowsScanner is the rows interface needed by onedb to enable QueryStruct and QueryJSON capability
func NewRowsScanner ¶
func NewRowsScanner(data interface{}) RowsScanner
NewRowsScanner returns a RowsScanner that can scan through a slice of data
type Scanner ¶
type Scanner interface {
Scan(dest ...interface{}) error
}
Scanner is the row interface needed by onedb to enable QueryStruct and QueryJSON capability
func NewScanner ¶
func NewScanner(data interface{}) Scanner
NewScanner returns a Scanner that can run Scan on a struct or pointer to struct