當前位置: 首頁>>代碼示例>>Golang>>正文


Golang CombinedStatus.State方法代碼示例

本文整理匯總了Golang中github.com/google/go-github/github.CombinedStatus.State方法的典型用法代碼示例。如果您正苦於以下問題:Golang CombinedStatus.State方法的具體用法?Golang CombinedStatus.State怎麽用?Golang CombinedStatus.State使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/google/go-github/github.CombinedStatus的用法示例。


在下文中一共展示了CombinedStatus.State方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: fakeRunGithubE2ESuccess

// fakeRunGithubE2ESuccess imitates jenkins running
func fakeRunGithubE2ESuccess(ciStatus *github.CombinedStatus, e2ePass, unitPass bool) {
	ciStatus.State = stringPtr("pending")
	for id := range ciStatus.Statuses {
		status := &ciStatus.Statuses[id]
		if *status.Context == jenkinsE2EContext || *status.Context == jenkinsUnitContext {
			status.State = stringPtr("pending")
		}
	}
	// short sleep like the test is running
	time.Sleep(500 * time.Millisecond)
	ciStatus.State = stringPtr("success")
	foundE2E := false
	foundUnit := false
	for id := range ciStatus.Statuses {
		status := &ciStatus.Statuses[id]
		if *status.Context == jenkinsE2EContext {
			setStatus(status, e2ePass)
			foundE2E = true
		}
		if *status.Context == jenkinsUnitContext {
			setStatus(status, unitPass)
			foundUnit = true
		}
	}
	if !foundE2E {
		addStatus(jenkinsE2EContext, e2ePass, ciStatus)
	}
	if !foundUnit {
		addStatus(jenkinsUnitContext, unitPass, ciStatus)
	}
}
開發者ID:resouer,項目名稱:contrib,代碼行數:32,代碼來源:submit-queue_test.go

示例2: fakeRunGithubE2ESuccess

// fakeRunGithubE2ESuccess imitates jenkins running
func fakeRunGithubE2ESuccess(ciStatus *github.CombinedStatus, context1Pass, context2Pass bool) {
	ciStatus.State = stringPtr("pending")
	for id := range ciStatus.Statuses {
		status := &ciStatus.Statuses[id]
		if *status.Context == requiredReTestContext1 || *status.Context == requiredReTestContext2 {
			status.State = stringPtr("pending")
		}
	}
	// short sleep like the test is running
	time.Sleep(500 * time.Millisecond)
	if context1Pass && context2Pass {
		ciStatus.State = stringPtr("success")
	}
	foundContext1 := false
	foundContext2 := false
	for id := range ciStatus.Statuses {
		status := &ciStatus.Statuses[id]
		if *status.Context == requiredReTestContext1 {
			setStatus(status, context1Pass)
			foundContext1 = true
		}
		if *status.Context == requiredReTestContext2 {
			setStatus(status, context2Pass)
			foundContext2 = true
		}
	}
	if !foundContext1 {
		addStatus(jenkinsE2EContext, context1Pass, ciStatus)
	}
	if !foundContext2 {
		addStatus(jenkinsUnitContext, context2Pass, ciStatus)
	}
}
開發者ID:danielibrahim,項目名稱:contrib,代碼行數:34,代碼來源:submit-queue_test.go

示例3: fakeRunGithubE2ESuccess

// fakeRunGithubE2ESuccess imitates the github e2e running, but indicates
// success after a short sleep
func fakeRunGithubE2ESuccess(ciStatus *github.CombinedStatus, shouldPass bool) {
	ciStatus.State = stringPtr("pending")
	for id := range ciStatus.Statuses {
		status := &ciStatus.Statuses[id]
		if *status.Context == gceE2EContext {
			status.State = stringPtr("pending")
			break
		}
	}
	// short sleep like the test is running
	time.Sleep(500 * time.Millisecond)
	ciStatus.State = stringPtr("success")
	found := false
	for id := range ciStatus.Statuses {
		status := &ciStatus.Statuses[id]
		if *status.Context == gceE2EContext {
			if shouldPass {
				status.State = stringPtr("success")
			} else {
				status.State = stringPtr("failure")
			}
			found = true
			break
		}
	}
	if !found {
		e2eStatus := github.RepoStatus{
			Context: stringPtr(gceE2EContext),
			State:   stringPtr("success"),
		}
		ciStatus.Statuses = append(ciStatus.Statuses, e2eStatus)
	}
}
開發者ID:josafat,項目名稱:contrib,代碼行數:35,代碼來源:submit-queue_test.go

示例4: updateStatusState

func updateStatusState(status *github.CombinedStatus) *github.CombinedStatus {
	prioMap := map[string]int{
		"pending": 4,
		"error":   3,
		"failure": 2,
		"success": 1,
		"":        0,
	}

	backMap := map[int]string{
		4: "pending",
		3: "error",
		2: "failure",
		1: "success",
		0: "",
	}

	sint := 1
	for _, s := range status.Statuses {
		newSint := prioMap[*s.State]
		if newSint > sint {
			sint = newSint
		}
	}
	status.State = stringPtr(backMap[sint])
	return status
}
開發者ID:krancour,項目名稱:kubernetes-contrib,代碼行數:27,代碼來源:github.go


注:本文中的github.com/google/go-github/github.CombinedStatus.State方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。