2013-07-02 22:28:50 +04:00
|
|
|
package commands
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/bmizerany/assert"
|
|
|
|
"github.com/jingweno/octokat"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestFetchAndMerge(t *testing.T) {
|
|
|
|
url := "https://github.com/jingweno/gh/pull/73"
|
2013-07-02 23:37:28 +04:00
|
|
|
number := 73
|
|
|
|
title := "title"
|
2013-07-02 22:28:50 +04:00
|
|
|
|
|
|
|
args := NewArgs([]string{"merge", url})
|
|
|
|
|
|
|
|
userLogin := "jingweno"
|
|
|
|
user := octokat.User{Login: userLogin}
|
|
|
|
|
|
|
|
repoPrivate := true
|
|
|
|
repo := octokat.Repository{Private: repoPrivate}
|
|
|
|
|
|
|
|
headRef := "new-feature"
|
2013-07-29 21:50:28 +04:00
|
|
|
head := octokat.Commit{Ref: headRef, Repo: repo, Label: "jingweno:new-feature"}
|
2013-07-02 22:28:50 +04:00
|
|
|
|
2013-07-02 23:37:28 +04:00
|
|
|
pullRequest := octokat.PullRequest{Number: number, Title: title, HTMLURL: url, User: user, Head: head}
|
2013-07-02 22:28:50 +04:00
|
|
|
|
|
|
|
err := fetchAndMerge(args, &pullRequest)
|
|
|
|
assert.Equal(t, nil, err)
|
|
|
|
|
|
|
|
cmds := args.Commands()
|
|
|
|
assert.Equal(t, 2, len(cmds))
|
|
|
|
|
|
|
|
cmd := cmds[0]
|
|
|
|
assert.Equal(t, "git fetch git@github.com:jingweno/gh.git +refs/heads/new-feature:refs/remotes/jingweno/new-feature", cmd.String())
|
|
|
|
|
|
|
|
cmd = cmds[1]
|
2013-07-02 23:31:23 +04:00
|
|
|
assert.Equal(t, "git merge jingweno/new-feature --no-ff -m Merge pull request #73 from jingweno/new-feature\n\ntitle", cmd.String())
|
2013-07-02 22:28:50 +04:00
|
|
|
}
|