當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。