コード例 #1
0
func NowStatus() *github.CombinedStatus {
	status := github_test.Status("mysha", []string{travisContext, jenkinsUnitContext, jenkinsE2EContext}, nil, nil, nil)
	for i := range status.Statuses {
		s := &status.Statuses[i]
		s.CreatedAt = timePtr(time.Now())
		s.UpdatedAt = timePtr(time.Now())
	}
	return status
}
コード例 #2
0
ファイル: stale-green-ci_test.go プロジェクト: raggi/contrib
func NowStatus() *github.CombinedStatus {
	status := github_test.Status("mysha", requiredContexts, nil, nil, nil)
	for i := range status.Statuses {
		s := &status.Statuses[i]
		s.CreatedAt = timePtr(time.Now())
		s.UpdatedAt = timePtr(time.Now())
	}
	return status
}
コード例 #3
0
ファイル: submit-queue_test.go プロジェクト: resouer/contrib
func GithubE2EFailStatus() *github.CombinedStatus {
	return github_test.Status("mysha", []string{travisContext, jenkinsUnitContext}, []string{jenkinsE2EContext}, nil, nil)
}
コード例 #4
0
func NoRetestFailStatus() *github.CombinedStatus {
	return github_test.Status("mysha", []string{requiredReTestContext1, requiredReTestContext2, notRequiredReTestContext1}, []string{notRequiredReTestContext2}, nil, nil)
}
コード例 #5
0
func SuccessStatus() *github.CombinedStatus {
	return github_test.Status("mysha", []string{requiredReTestContext1, requiredReTestContext2, notRequiredReTestContext1, notRequiredReTestContext2}, nil, nil, nil)
}
コード例 #6
0
ファイル: github_test.go プロジェクト: krousey/contrib
func TestComputeStatus(t *testing.T) {
	contextS := []string{"context"}
	otherS := []string{"other context"}
	bothS := []string{"context", "other context"}
	firstS := []string{"context", "crap"}

	tests := []struct {
		combinedStatus   *github.CombinedStatus
		requiredContexts []string
		expected         string
	}{
		// test no context specified
		{
			combinedStatus: github_test.Status("mysha", nil, nil, nil, nil),
			expected:       "success",
		},
		{
			combinedStatus: &github.CombinedStatus{
				State: stringPtr("pending"),
				SHA:   stringPtr("mysha"),
			},
			expected: "pending",
		},
		{
			combinedStatus: &github.CombinedStatus{
				State: stringPtr("failure"),
				SHA:   stringPtr("mysha"),
			},
			expected: "failure",
		},
		{
			combinedStatus: &github.CombinedStatus{
				State: stringPtr("error"),
				SHA:   stringPtr("mysha"),
			},
			expected: "error",
		},
		// test missing subcontext requested but missing
		{
			combinedStatus:   github_test.Status("mysha", otherS, nil, nil, nil),
			requiredContexts: contextS,
			expected:         "incomplete",
		},
		{
			combinedStatus:   github_test.Status("mysha", nil, otherS, nil, nil),
			requiredContexts: contextS,
			expected:         "incomplete",
		},
		{
			combinedStatus:   github_test.Status("mysha", nil, nil, otherS, nil),
			requiredContexts: contextS,
			expected:         "incomplete",
		},
		{
			combinedStatus:   github_test.Status("mysha", nil, nil, nil, otherS),
			requiredContexts: contextS,
			expected:         "incomplete",
		},
		// test subcontext present and requested
		{
			combinedStatus:   github_test.Status("mysha", contextS, nil, nil, nil),
			requiredContexts: contextS,
			expected:         "success",
		},
		{
			combinedStatus:   github_test.Status("mysha", nil, nil, contextS, nil),
			requiredContexts: contextS,
			expected:         "pending",
		},
		{
			combinedStatus:   github_test.Status("mysha", nil, nil, nil, contextS),
			requiredContexts: contextS,
			expected:         "error",
		},
		{
			combinedStatus:   github_test.Status("mysha", nil, contextS, nil, nil),
			requiredContexts: contextS,
			expected:         "failure",
		},
		// test failed PR but the one we care about is passed
		{
			combinedStatus:   github_test.Status("mysha", contextS, otherS, nil, nil),
			requiredContexts: contextS,
			expected:         "success",
		},
		// test failed because we need both, but one is failed
		{
			combinedStatus:   github_test.Status("mysha", contextS, otherS, nil, nil),
			requiredContexts: bothS,
			expected:         "failure",
		},
		// test failed because we need both, bot one isn't present
		{
			combinedStatus:   github_test.Status("mysha", firstS, nil, nil, nil),
			requiredContexts: bothS,
			expected:         "incomplete",
		},
	}

	for _, test := range tests {
		// ease of use, reduce boilerplate in test cases
		if test.requiredContexts == nil {
			test.requiredContexts = []string{}
		}
		status := computeStatus(test.combinedStatus, test.requiredContexts)
		if test.expected != status {
			t.Errorf("expected: %s, saw %s for %v", test.expected, status, test.combinedStatus)
		}
	}
}
コード例 #7
0
ファイル: submit-queue_test.go プロジェクト: jangaraj/contrib
func GithubE2EFailStatus() *github.CombinedStatus {
	return github_test.Status("mysha", []string{claContext, shippableContext, travisContext}, []string{gceE2EContext}, nil, nil)
}
コード例 #8
0
ファイル: submit-queue_test.go プロジェクト: jangaraj/contrib
func JenkinsCIGreenShippablePendingStatus() *github.CombinedStatus {
	return github_test.Status("mysha", []string{claContext, jenkinsCIContext, travisContext, gceE2EContext}, nil, []string{shippableContext}, nil)
}
コード例 #9
0
ファイル: submit-queue_test.go プロジェクト: jangaraj/contrib
func SuccessStatus() *github.CombinedStatus {
	return github_test.Status("mysha", []string{claContext, shippableContext, travisContext, jenkinsCIContext, gceE2EContext}, nil, nil, nil)
}
コード例 #10
0
ファイル: stale-green-ci_test.go プロジェクト: raggi/contrib
func OldStatus() *github.CombinedStatus {
	return github_test.Status("mysha", requiredContexts, nil, nil, nil)
}