-
Notifications
You must be signed in to change notification settings - Fork 128
/
repo_pull_test.go
47 lines (41 loc) · 1.13 KB
/
repo_pull_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// Copyright 2020 The Gogs Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
package git
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestRepository_MergeBase(t *testing.T) {
t.Run("no merge base", func(t *testing.T) {
mb, err := testrepo.MergeBase("0eedd79eba4394bbef888c804e899731644367fe", "bad_revision")
assert.Equal(t, ErrNoMergeBase, err)
assert.Empty(t, mb)
})
tests := []struct {
base string
head string
opt MergeBaseOptions
expMergeBase string
}{
{
base: "4e59b72440188e7c2578299fc28ea425fbe9aece",
head: "0eedd79eba4394bbef888c804e899731644367fe",
expMergeBase: "4e59b72440188e7c2578299fc28ea425fbe9aece",
},
{
base: "master",
head: "release-1.0",
expMergeBase: "0eedd79eba4394bbef888c804e899731644367fe",
},
}
for _, test := range tests {
t.Run("", func(t *testing.T) {
mb, err := testrepo.MergeBase(test.base, test.head, test.opt)
if err != nil {
t.Fatal(err)
}
assert.Equal(t, test.expMergeBase, mb)
})
}
}