~egtann/sjs

b862d93bde3c08eda5076f8e8c40665fd20b647b — Evan Tann 1 year, 2 months ago aa595c9
add HTTPClient interface
1 files changed, 10 insertions(+), 1 deletions(-)

M http/client.go
M http/client.go => http/client.go +10 -1
@@ 18,7 18,7 @@ import (
type Client struct {
	Jobs []*sjs.JobData

	client    *http.Client
	client    HTTPClient
	apiKey    string
	selfURL   string
	serverURL string


@@ 39,6 39,15 @@ func NewClient(selfURL, sjsURL, apiKey, host, role string) *Client {
	}
}

type HTTPClient interface {
	Do(*http.Request) (*http.Response, error)
}

func (c *Client) WithHTTPClient(h HTTPClient) *Client {
	c.client = h
	return c
}

// WithJobs appends jobs that can be performed by the client.
func (c *Client) WithJobs(jobData ...*sjs.JobData) *Client {
	// Typically Err() is called before this but on a