MCPcopy Create free account
hub / github.com/gogs/gogs / TestModuler_PullRequestMeta

Function TestModuler_PullRequestMeta

internal/gitutil/pull_request_test.go:11–104  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

9)
10
11func TestModuler_PullRequestMeta(t *testing.T) {
12 headPath := "/head/path"
13 basePath := "/base/path"
14 headBranch := "head_branch"
15 baseBranch := "base_branch"
16 mergeBase := "MERGE-BASE"
17 changedFiles := []string{"a.go", "b.txt"}
18 commits := []*git.Commit{
19 {ID: git.MustIDFromString("adfd6da3c0a3fb038393144becbf37f14f780087")},
20 }
21
22 SetMockModuleStore(t, &MockModuleStore{
23 remoteAdd: func(repoPath, name, url string, opts ...git.RemoteAddOptions) error {
24 if repoPath != headPath {
25 return errors.Newf("repoPath: want %q but got %q", headPath, repoPath)
26 } else if name == "" {
27 return errors.New("empty name")
28 } else if url != basePath {
29 return errors.Newf("url: want %q but got %q", basePath, url)
30 }
31
32 if len(opts) == 0 {
33 return errors.New("no options")
34 } else if !opts[0].Fetch {
35 return errors.Newf("opts.Fetch: want %v but got %v", true, opts[0].Fetch)
36 }
37
38 return nil
39 },
40 mergeBase: func(repoPath, base, head string, opts ...git.MergeBaseOptions) (string, error) {
41 if repoPath != headPath {
42 return "", errors.Newf("repoPath: want %q but got %q", headPath, repoPath)
43 } else if base == "" {
44 return "", errors.New("empty base")
45 } else if head != headBranch {
46 return "", errors.Newf("head: want %q but got %q", headBranch, head)
47 }
48
49 return mergeBase, nil
50 },
51 log: func(repoPath, rev string, opts ...git.LogOptions) ([]*git.Commit, error) {
52 if repoPath != headPath {
53 return nil, errors.Newf("repoPath: want %q but got %q", headPath, repoPath)
54 }
55
56 expRev := mergeBase + "..." + headBranch
57 if rev != expRev {
58 return nil, errors.Newf("rev: want %q but got %q", expRev, rev)
59 }
60
61 return commits, nil
62 },
63 diffNameOnly: func(repoPath, base, head string, opts ...git.DiffNameOnlyOptions) ([]string, error) {
64 if repoPath != headPath {
65 return nil, errors.Newf("repoPath: want %q but got %q", headPath, repoPath)
66 } else if base == "" {
67 return nil, errors.New("empty base")
68 } else if head != headBranch {

Callers

nothing calls this directly

Calls 2

SetMockModuleStoreFunction · 0.85
PullRequestMetaMethod · 0.65

Tested by

no test coverage detected