diff options
| author | Carlos Martín Nieto <[email protected]> | 2015-09-18 10:52:37 +0200 |
|---|---|---|
| committer | Carlos Martín Nieto <[email protected]> | 2015-09-18 10:52:37 +0200 |
| commit | 0522886781055d59b780e00fddf3c8f7c9e118dc (patch) | |
| tree | 797b7644292addcd518dbfea092aa9f3fd1e1e6c /clone_test.go | |
| parent | b3e7705c48f038ef335204a2a9e1ee829784c30e (diff) | |
| parent | ebf7f15bf9c585102b1c39f6bec5f61a37d18802 (diff) | |
Merge remote-tracking branch 'origin/master' into next
Diffstat (limited to 'clone_test.go')
| -rw-r--r-- | clone_test.go | 45 |
1 files changed, 44 insertions, 1 deletions
diff --git a/clone_test.go b/clone_test.go index 7cdc362..a6bbf94 100644 --- a/clone_test.go +++ b/clone_test.go @@ -5,8 +5,11 @@ import ( "testing" ) -func TestClone(t *testing.T) { +const ( + REMOTENAME = "testremote" +) +func TestClone(t *testing.T) { repo := createTestRepo(t) defer cleanupTestRepo(t, repo) @@ -30,3 +33,43 @@ func TestClone(t *testing.T) { t.Fatal("reference in clone does not match original ref") } } + +func TestCloneWithCallback(t *testing.T) { + testPayload := 0 + + repo := createTestRepo(t) + defer cleanupTestRepo(t, repo) + + seedTestRepo(t, repo) + + path, err := ioutil.TempDir("", "git2go") + checkFatal(t, err) + + opts := CloneOptions{ + Bare: true, + RemoteCreateCallback: func(r *Repository, name, url string) (*Remote, ErrorCode) { + testPayload += 1 + + remote, err := r.Remotes.Create(REMOTENAME, url) + if err != nil { + return nil, ErrGeneric + } + + return remote, ErrOk + }, + } + + repo2, err := Clone(repo.Path(), path, &opts) + defer cleanupTestRepo(t, repo2) + + checkFatal(t, err) + + if testPayload != 1 { + t.Fatal("Payload's value has not been changed") + } + + remote, err := repo2.Remotes.Lookup(REMOTENAME) + if err != nil || remote == nil { + t.Fatal("Remote was not created properly") + } +} |
