Exemplo n.º 1
0
func TestClientHaltsIfSchemaCannotBeBuilt(t *testing.T) {
	schema := new(api.RequestSchema)

	lifecycle := new(MockLifecycle)
	lifecycle.On("Build", schema).Return(nil, errors.New("uh-oh!")).Once()

	client := api.NewClient(lifecycle)
	resp, err := client.Do(schema)

	lifecycle.AssertExpectations(t)
	assert.Nil(t, resp)
	assert.Equal(t, "uh-oh!", err.Error())
}
Exemplo n.º 2
0
func TestClientReturnsCleanupErrors(t *testing.T) {
	schema := new(api.RequestSchema)
	req := new(http.Request)
	resp := new(api.HttpResponse)

	lifecycle := new(MockLifecycle)
	lifecycle.On("Build", schema).Return(req, nil).Once()
	lifecycle.On("Execute", req, schema.Into).Return(resp, nil).Once()
	lifecycle.On("Cleanup", resp).Return(errors.New("uh-oh!")).Once()

	client := api.NewClient(lifecycle)
	r1, err := client.Do(schema)

	lifecycle.AssertExpectations(t)
	assert.Nil(t, r1)
	assert.Equal(t, "uh-oh!", err.Error())
}
Exemplo n.º 3
0
func TestClientUsesLifecycleToExecuteSchemas(t *testing.T) {
	schema := new(api.RequestSchema)
	req := new(http.Request)
	resp := new(api.HttpResponse)

	lifecycle := new(MockLifecycle)
	lifecycle.On("Build", schema).Return(req, nil).Once()
	lifecycle.On("Execute", req, schema.Into).Return(resp, nil).Once()
	lifecycle.On("Cleanup", resp).Return(nil).Once()

	client := api.NewClient(lifecycle)
	r1, err := client.Do(schema)

	assert.Equal(t, resp, r1)
	assert.Nil(t, err)
	lifecycle.AssertExpectations(t)
}
Exemplo n.º 4
0
	"github.com/github/git-lfs/api"
	"github.com/github/git-lfs/config"
	"github.com/github/git-lfs/errors"
	"github.com/github/git-lfs/git"
	"github.com/github/git-lfs/lfs"
	"github.com/github/git-lfs/tools"
	"github.com/github/git-lfs/transfer"
)

// Populate man pages
//go:generate go run ../docs/man/mangen.go

var (
	// API is a package-local instance of the API client for use within
	// various command implementations.
	API = api.NewClient(nil)

	Debugging    = false
	ErrorBuffer  = &bytes.Buffer{}
	ErrorWriter  = io.MultiWriter(os.Stderr, ErrorBuffer)
	OutputWriter = io.MultiWriter(os.Stdout, ErrorBuffer)
	ManPages     = make(map[string]string, 20)
	cfg          = config.Config

	includeArg string
	excludeArg string
)

// TransferManifest builds a transfer.Manifest from the commands package global
// cfg var.
func TransferManifest() *transfer.Manifest {