当前位置: 首页>>代码示例>>Golang>>正文


Golang testing.PullRequest函数代码示例

本文整理汇总了Golang中k8s/io/contrib/mungegithub/github/testing.PullRequest函数的典型用法代码示例。如果您正苦于以下问题:Golang PullRequest函数的具体用法?Golang PullRequest怎么用?Golang PullRequest使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了PullRequest函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: NonWhitelistUserPR

func NonWhitelistUserPR() *github.PullRequest {
	return github_test.PullRequest(noWhitelistUser, false, true, true)
}
开发者ID:resouer,项目名称:contrib,代码行数:3,代码来源:submit-queue_test.go

示例2: UnMergeablePR

func UnMergeablePR() *github.PullRequest {
	return github_test.PullRequest(whitelistUser, false, true, false)
}
开发者ID:resouer,项目名称:contrib,代码行数:3,代码来源:submit-queue_test.go

示例3: UndeterminedMergeablePR

func UndeterminedMergeablePR() *github.PullRequest {
	return github_test.PullRequest(whitelistUser, false, false, false)
}
开发者ID:resouer,项目名称:contrib,代码行数:3,代码来源:submit-queue_test.go

示例4: ValidPR

func ValidPR() *github.PullRequest {
	return github_test.PullRequest(whitelistUser, false, true, true)
}
开发者ID:resouer,项目名称:contrib,代码行数:3,代码来源:submit-queue_test.go

示例5: UndeterminedMergeablePR

func UndeterminedMergeablePR() *github.PullRequest {
	return github_test.PullRequest(someUserName, false, false, false)
}
开发者ID:danielibrahim,项目名称:contrib,代码行数:3,代码来源:submit-queue_test.go

示例6: UnMergeablePR

func UnMergeablePR() *github.PullRequest {
	return github_test.PullRequest(someUserName, false, true, false)
}
开发者ID:danielibrahim,项目名称:contrib,代码行数:3,代码来源:submit-queue_test.go

示例7: ValidPR

func ValidPR() *github.PullRequest {
	return github_test.PullRequest(someUserName, false, true, true)
}
开发者ID:danielibrahim,项目名称:contrib,代码行数:3,代码来源:submit-queue_test.go

示例8: TestAssignFixes

func TestAssignFixes(t *testing.T) {
	runtime.GOMAXPROCS(runtime.NumCPU())

	tests := []struct {
		name       string
		assignee   string
		pr         *github.PullRequest
		prIssue    *github.Issue
		prBody     string
		fixesIssue *github.Issue
	}{
		{
			name:       "fixes an issue",
			assignee:   "dev45",
			pr:         github_test.PullRequest("dev45", false, true, true),
			prIssue:    github_test.Issue("fred", 7779, []string{}, true),
			prBody:     "does stuff and fixes #8889.",
			fixesIssue: github_test.Issue("jill", 8889, []string{}, true),
		},
	}
	for _, test := range tests {
		test.prIssue.Body = &test.prBody
		client, server, mux := github_test.InitServer(t, test.prIssue, test.pr, nil, nil, nil, nil)
		path := fmt.Sprintf("/repos/o/r/issues/%d", *test.fixesIssue.Number)
		mux.HandleFunc(path, func(w http.ResponseWriter, r *http.Request) {
			data, err := json.Marshal(test.fixesIssue)
			if err != nil {
				t.Errorf("%v", err)
			}
			if r.Method != "PATCH" && r.Method != "GET" {
				t.Errorf("Unexpected method: expected: GET/PATCH got: %s", r.Method)
			}
			if r.Method == "PATCH" {
				body, _ := ioutil.ReadAll(r.Body)

				type IssuePatch struct {
					Assignee string
				}
				var ip IssuePatch
				err := json.Unmarshal(body, &ip)
				if err != nil {
					fmt.Println("error:", err)
				}
				if ip.Assignee != test.assignee {
					t.Errorf("Patching the incorrect Assignee %v instead of %v", ip.Assignee, test.assignee)
				}
			}
			w.WriteHeader(http.StatusOK)
			w.Write(data)
		})

		config := &github_util.Config{}
		config.Org = "o"
		config.Project = "r"
		config.SetClient(client)

		c := AssignFixesMunger{}
		err := c.Initialize(config, nil)
		if err != nil {
			t.Fatalf("%v", err)
		}

		err = c.EachLoop()
		if err != nil {
			t.Fatalf("%v", err)
		}

		obj, err := config.GetObject(*test.prIssue.Number)
		if err != nil {
			t.Fatalf("%v", err)
		}

		c.Munge(obj)
		server.Close()
	}
}
开发者ID:raggi,项目名称:contrib,代码行数:76,代码来源:assign-fixes_test.go


注:本文中的k8s/io/contrib/mungegithub/github/testing.PullRequest函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。