lfs: remove TransferManifest()

This commit is contained in:
risk danger olson 2017-01-03 16:01:45 -07:00
parent 7878bc3583
commit 3719fece12
3 changed files with 36 additions and 33 deletions

@ -41,7 +41,13 @@ var (
// TransferManifest builds a tq.Manifest from the commands package global
// cfg var.
func TransferManifest() *tq.Manifest {
return lfs.TransferManifest(cfg)
return buildTransferManifest("download", cfg.CurrentRemote)
}
// buildTransferManifest builds a tq.Manifest from the global os and git
// environments.
func buildTransferManifest(operation, remote string) *tq.Manifest {
return tq.NewManifestWithClient(newAPIClient(), operation, remote)
}
func newAPIClient() *lfsapi.Client {

@ -118,11 +118,6 @@ func Environ(cfg *config.Configuration, manifest *tq.Manifest) []string {
return env
}
// TransferManifest builds a tq.Manifest using the given cfg.
func TransferManifest(cfg *config.Configuration) *tq.Manifest {
return tq.NewManifestWithGitEnv(string(cfg.Access("download")), cfg.Git)
}
func InRepo() bool {
return config.LocalGitDir != ""
}

@ -3,48 +3,50 @@ package lfs
import (
"testing"
"github.com/git-lfs/git-lfs/config"
"github.com/git-lfs/git-lfs/lfsapi"
"github.com/git-lfs/git-lfs/tq"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestManifestIsConfigurable(t *testing.T) {
cfg := config.NewFrom(config.Values{
Git: map[string]string{
cli, err := lfsapi.NewClient(nil, lfsapi.Env(map[string]string{
"lfs.transfer.maxretries": "3",
},
})
m := TransferManifest(cfg)
}))
require.Nil(t, err)
m := tq.NewManifestWithClient(cli, "", "")
assert.Equal(t, 3, m.MaxRetries())
}
func TestManifestChecksNTLM(t *testing.T) {
cfg := config.NewFrom(config.Values{
Git: map[string]string{
cli, err := lfsapi.NewClient(nil, lfsapi.Env(map[string]string{
"lfs.url": "http://foo",
"lfs.http://foo.access": "ntlm",
"lfs.concurrenttransfers": "3",
},
})
m := TransferManifest(cfg)
}))
require.Nil(t, err)
m := tq.NewManifestWithClient(cli, "", "")
assert.Equal(t, 1, m.MaxRetries())
}
func TestManifestClampsValidValues(t *testing.T) {
cfg := config.NewFrom(config.Values{
Git: map[string]string{
cli, err := lfsapi.NewClient(nil, lfsapi.Env(map[string]string{
"lfs.transfer.maxretries": "-1",
},
})
m := TransferManifest(cfg)
}))
require.Nil(t, err)
m := tq.NewManifestWithClient(cli, "", "")
assert.Equal(t, 1, m.MaxRetries())
}
func TestManifestIgnoresNonInts(t *testing.T) {
cfg := config.NewFrom(config.Values{
Git: map[string]string{
cli, err := lfsapi.NewClient(nil, lfsapi.Env(map[string]string{
"lfs.transfer.maxretries": "not_an_int",
},
})
m := TransferManifest(cfg)
}))
require.Nil(t, err)
m := tq.NewManifestWithClient(cli, "", "")
assert.Equal(t, 1, m.MaxRetries())
}