-
Notifications
You must be signed in to change notification settings - Fork 89
/
github_push_test.go
66 lines (60 loc) · 1.72 KB
/
github_push_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
//go:build e2e
// +build e2e
package test
import (
"context"
"fmt"
"os"
"testing"
tgithub "github.com/openshift-pipelines/pipelines-as-code/test/pkg/github"
)
func TestGithubPush(t *testing.T) {
if os.Getenv("NIGHTLY_E2E_TEST") != "true" {
t.Skip("Skipping test since only enabled for nightly")
}
ctx := context.Background()
if os.Getenv("TEST_GITHUB_REPO_OWNER_WEBHOOK") == "" {
g := &tgithub.PRTest{
Label: "Github push request on Webhook",
YamlFiles: []string{"testdata/pipelinerun-on-push.yaml"},
SecondController: false,
Webhook: true,
}
g.RunPushRequest(ctx, t)
defer g.TearDown(ctx, t)
} else {
t.Skip("TEST_GITHUB_REPO_OWNER_WEBHOOK is not set")
}
g := &tgithub.PRTest{
Label: "Github apps push request",
YamlFiles: []string{"testdata/pipelinerun-on-push.yaml"},
}
g.RunPushRequest(ctx, t)
defer g.TearDown(ctx, t)
}
func TestGithubSecondPush(t *testing.T) {
ctx := context.Background()
g := &tgithub.PRTest{
Label: "Github push request",
YamlFiles: []string{"testdata/pipelinerun-on-push.yaml"},
SecondController: true,
}
g.RunPushRequest(ctx, t)
defer g.TearDown(ctx, t)
}
func TestGithubPushRequestCELMatchOnTitle(t *testing.T) {
ctx := context.Background()
for _, onWebhook := range []bool{false, true} {
if onWebhook && os.Getenv("TEST_GITHUB_REPO_OWNER_WEBHOOK") == "" {
t.Skip("TEST_GITHUB_REPO_OWNER_WEBHOOK is not set")
continue
}
g := &tgithub.PRTest{
Label: fmt.Sprintf("Github push request test CEL match on title onWebhook=%v", onWebhook),
YamlFiles: []string{"testdata/pipelinerun-cel-annotation-for-title-match.yaml"},
Webhook: onWebhook,
}
g.RunPushRequest(ctx, t)
defer g.TearDown(ctx, t)
}
}