Documentation
¶
Index ¶
- Variables
- func AssignResource(model coal.Model, res *jsonapi.Resource) error
- func ConvertModel(model coal.Model) (*jsonapi.Resource, error)
- func Merge(base interface{}, with ...interface{}) interface{}
- func N() int64
- func Now() time.Time
- func S(str string) string
- func T(t string) time.Time
- type Client
- func (c *Client) Create(model coal.Model) (coal.Model, *jsonapi.Document, error)
- func (c *Client) Delete(model coal.Model) error
- func (c *Client) Find(model coal.Model, reqs ...jsonapi.Request) (coal.Model, *jsonapi.Document, error)
- func (c *Client) List(model coal.Model, reqs ...jsonapi.Request) ([]coal.Model, *jsonapi.Document, error)
- func (c *Client) Update(model coal.Model) (coal.Model, *jsonapi.Document, error)
- type Config
- type Factory
- type Result
- type Tester
- func (t *Tester) Authenticate(clientID, username, password string, scope ...string)
- func (t *Tester) Create(tt *testing.T, model, response, result coal.Model) Result
- func (t *Tester) CreateError(tt *testing.T, model coal.Model, e error) Result
- func (t *Tester) Delete(tt *testing.T, model, result coal.Model) Result
- func (t *Tester) DeleteError(tt *testing.T, model coal.Model, e error) Result
- func (t *Tester) Find(tt *testing.T, model coal.Model, response coal.Model) Result
- func (t *Tester) FindError(tt *testing.T, model coal.Model, e error) Result
- func (t *Tester) Invalidate()
- func (t *Tester) List(tt *testing.T, model coal.Model, response []coal.Model) Result
- func (t *Tester) ListError(tt *testing.T, model coal.Model, e error) Result
- func (t *Tester) Update(tt *testing.T, model, response, result coal.Model) Result
- func (t *Tester) UpdateError(tt *testing.T, model coal.Model, e error) Result
Constants ¶
This section is empty.
Variables ¶
var AccessDenied = fire.ErrAccessDenied.Self().(*xo.Err).Err
AccessDenied is the raw access denied error value.
var ResourceNotFound = fire.ErrResourceNotFound.Self().(*xo.Err).Err
ResourceNotFound is the raw resource not found error value.
Functions ¶
func AssignResource ¶
AssignResource will assign the provided resource to the specified model.
func ConvertModel ¶
ConvertModel will convert the provided model to a resource.
func Merge ¶
func Merge(base interface{}, with ...interface{}) interface{}
Merge will merge the specified base value with the provided values and return the base value.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client wraps a jsonapi.Client to directly interact with models.
func (*Client) Find ¶
func (c *Client) Find(model coal.Model, reqs ...jsonapi.Request) (coal.Model, *jsonapi.Document, error)
Find will find and return the provided model.
type Config ¶
type Config struct {
Store *coal.Store
Models []coal.Model
Handler http.Handler
DataNamespace string
AuthNamespace string
TokenEndpoint string
Authorizer func(req *http.Request)
Debug bool
}
Config provides configuration of a tester.
type Factory ¶
type Factory struct {
// contains filtered or unexported fields
}
Factory is model factory for tests.
func NewFactory ¶
NewFactory creates and returns a new factory.
func (*Factory) Insert ¶
Insert make and insert a new model with the provided models merged into the registered base model.
type Tester ¶
type Tester struct {
*fire.Tester
RawClient *http.Client
DataClient *Client
AuthClient *oauth2.Client
AuthToken string
}
Tester provides a high-level unit test facility.
func (*Tester) Authenticate ¶
Authenticate will request an access token using the provided credentials.
func (*Tester) Create ¶
Create will create the provided model and validate the response and result if requested.
func (*Tester) CreateError ¶
CreateError will create the provided model and expect and error.
func (*Tester) DeleteError ¶
DeleteError will delete the provided model and expect an error.
func (*Tester) Invalidate ¶
func (t *Tester) Invalidate()
Invalidate will clear the current authentication.