Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalidToken is the error returned when the token is invalid. ErrInvalidToken = errors.New("invalid token") // ErrMalformedJSON is the error returned when the JSON is malformed. ErrMalformedJSON = errors.New("malformed json") )
var ( // ErrEndOfLine is the error returned when the end of the line is reached. ErrEndOfLine = errors.New("end of line") )
Functions ¶
This section is empty.
Types ¶
type Case ¶
type Case struct {
// Name is the name of the test case.
Name string `json:"case_name"`
// Arrange
Database `json:"database"`
// Input
Request `json:"request"`
// Output
Response `json:"response"`
}
Case is a test case.
type Database ¶
type Database struct {
// SetUp is the set of set up queries to run before the test case.
SetUp []string `json:"set_up"`
// TearDown is the set of tear down queries to run after the test case.
TearDown []string `json:"tear_down"`
}
Database is a database to run the test case against.
type DbExecuter ¶
type DbExecuter interface {
// Exec executes queries on the database.
Exec(queries ...string) (err error)
}
DbExecuter is an interface for executing queries on a database.
type DbExecuterMock ¶
DbExecuterMock is a mock of dbexecuter.
func NewDbExecuterMock ¶
func NewDbExecuterMock() *DbExecuterMock
NewDbExecuterMock creates a new dbexecuter mock.
func (*DbExecuterMock) Exec ¶
func (m *DbExecuterMock) Exec(queries ...string) (err error)
Exec mocks base method.
type DbExecuterMySQL ¶
type DbExecuterMySQL struct {
// contains filtered or unexported fields
}
DbExecuterMySQL is a MySQL database executer.
func NewDbExecuterMySQL ¶
func NewDbExecuterMySQL(db *sql.DB) *DbExecuterMySQL
NewDbExecuterMySQL creates a new MySQL database executer.
func (*DbExecuterMySQL) Exec ¶
func (e *DbExecuterMySQL) Exec(queries ...string) (err error)
Exec executes queries on the database.
type ReaderJSON ¶
type ReaderJSON struct {
// contains filtered or unexported fields
}
ReaderJSON is a reader of test cases in JSON format.
func NewReaderJSON ¶
func NewReaderJSON(decoder *json.Decoder, ch chan CaseErr) *ReaderJSON
NewReaderJSON creates a new reader of test cases in JSON format.
func (*ReaderJSON) Read ¶
func (r *ReaderJSON) Read() (c Case, err error)
Read reads the next test case.
func (*ReaderJSON) Stream ¶
func (r *ReaderJSON) Stream()
Stream is a concurrent reader of test cases
type ReaderMock ¶
ReaderMock is a mock of Reader.
func NewReaderMock ¶
func NewReaderMock() (m *ReaderMock)
NewReaderMock creates a new mock of Reader.
type Reporter ¶
type Reporter interface {
// Report reports the result of the test case.
Report(c *Case, w *http.Response) (err error)
}
Reporter is a reporter of test cases.
type ReporterDefault ¶
type ReporterDefault struct {
// contains filtered or unexported fields
}
ReporterDefault is the default reporter of test cases.
func NewReporterDefault ¶
func NewReporterDefault(excludedHeaders []string) *ReporterDefault
NewReporterDefault creates a new default reporter.
type ReporterMock ¶
ReporterMock is a mock of reporter.
func NewReporterMock ¶
func NewReporterMock() *ReporterMock
NewReporterMock creates a new reporter mock.
type Request ¶
type Request struct {
// Method is the HTTP method to use for the request.
Method string `json:"method"`
// Path is the path to use for the request.
Path string `json:"path"`
// Query is the set of query parameters to use for the request.
Query map[string]string `json:"query"`
// Body is the body to use for the request.
Body any `json:"body"`
// Header is the set of headers to use for the request.
Header http.Header `json:"header"`
}
Request is a request to make for the test case.
type RequesterDefault ¶
type RequesterDefault struct {
// contains filtered or unexported fields
}
RequesterDefault is the default requester.
func NewRequesterDefault ¶
func NewRequesterDefault(serverAddr string, client *http.Client) *RequesterDefault
NewRequesterDefault creates a new default requester.
type RequesterMock ¶
RequesterMock is a mock of requester.
func NewRequesterMock ¶
func NewRequesterMock() *RequesterMock
NewRequesterMock creates a new requester mock.
type Response ¶
type Response struct {
// Code is the expected status code of the response.
Code int `json:"code"`
// Body is the expected body of the response.
Body any `json:"body"`
// Header is the expected set of headers of the response.
Header http.Header `json:"header"`
}
Response is the expected response of the test case.