Documentation
¶
Index ¶
- type Server
- type TestServer
- func (t *TestServer) NewAuthenticatedRequest(method, target, userId string, body io.Reader) *http.Request
- func (t *TestServer) SeedBill(userId string) map[string]interface{}
- func (t *TestServer) SeedPayment(billId string) map[string]interface{}
- func (t *TestServer) SeedUser() map[string]interface{}
- func (t *TestServer) Shutdown()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Server ¶
type Server struct { Port string Version string Router *httprouter.Router Validator validator.Validator JwtSignatory *jwt.JwtSignatory DB *sql.DB }
Server is a struct responsible for managing a *httprouter.Router. All HandlerFunc Closures hang off of this struct, so all HandlerFunc's have access to the server values.
type TestServer ¶
type TestServer struct { Server EphemeralDatabase *database.EphemeralDatabase }
TestServer is a utility Server wrapper that is used to simplify writing integration tests. This really serves two purposes:
1. Plug all of the dependencies up in one place 2. Spin up an EphemeralDatabase that can be Terminated w/ a Shutdown function
func NewTestServer ¶
func NewTestServer() (*TestServer, error)
func (*TestServer) NewAuthenticatedRequest ¶
func (t *TestServer) NewAuthenticatedRequest(method, target, userId string, body io.Reader) *http.Request
NewAuthenticatedRequest generates a request that's authenticated as if the user with userId has actually gone through a proper authentication flow.
func (*TestServer) SeedBill ¶
func (t *TestServer) SeedBill(userId string) map[string]interface{}
Seeds a random Bill into our TestServer's database. This returns a map[string]interface{} for ease of result comparison, as the output of a parsed HTTPRecorder's result will be untyped.
func (*TestServer) SeedPayment ¶
func (t *TestServer) SeedPayment(billId string) map[string]interface{}
Seeds a random Payment into our TestServer's database. This returns a map[string]interface{} for ease of result comparison, as the output of a parsed HTTPRecorder's result will be untyped.
func (*TestServer) SeedUser ¶
func (t *TestServer) SeedUser() map[string]interface{}
Seeds a random User into our TestServer's database. This returns a map[string]interface{} for ease of result comparison, as the output of a parsed HTTPRecorder's result will be untyped.
func (*TestServer) Shutdown ¶
func (t *TestServer) Shutdown()