Fix webhook payload in integration test

This commit is contained in:
Hidetake Iwata 2021-02-20 21:08:23 +09:00
parent ebc3970b84
commit dfbe53dcca
1 changed files with 6 additions and 11 deletions

View File

@ -9,7 +9,6 @@ import (
"k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime"
"net/http" "net/http"
"net/http/httptest" "net/http/httptest"
"strings"
"time" "time"
"github.com/summerwind/actions-runner-controller/github/fake" "github.com/summerwind/actions-runner-controller/github/fake"
@ -297,14 +296,14 @@ var _ = Context("INTEGRATION: Inside of a new namespace", func() {
// Scale-up to 2 replicas on first pull_request create webhook event // Scale-up to 2 replicas on first pull_request create webhook event
{ {
env.SendPullRequestEvent("test/valid", "main", "created") env.SendPullRequestEvent("test", "valid", "main", "created")
ExpectRunnerSetsCountEventuallyEquals(ctx, ns.Name, 1, "runner sets after webhook") ExpectRunnerSetsCountEventuallyEquals(ctx, ns.Name, 1, "runner sets after webhook")
ExpectRunnerSetsManagedReplicasCountEventuallyEquals(ctx, ns.Name, 2, "runners after first webhook event") ExpectRunnerSetsManagedReplicasCountEventuallyEquals(ctx, ns.Name, 2, "runners after first webhook event")
} }
// Scale-up to 3 replicas on second pull_request create webhook event // Scale-up to 3 replicas on second pull_request create webhook event
{ {
env.SendPullRequestEvent("test/valid", "main", "created") env.SendPullRequestEvent("test", "valid", "main", "created")
ExpectRunnerSetsManagedReplicasCountEventuallyEquals(ctx, ns.Name, 3, "runners after second webhook event") ExpectRunnerSetsManagedReplicasCountEventuallyEquals(ctx, ns.Name, 3, "runners after second webhook event")
} }
}) })
@ -386,7 +385,7 @@ var _ = Context("INTEGRATION: Inside of a new namespace", func() {
// Scale-up to 4 replicas on first check_run create webhook event // Scale-up to 4 replicas on first check_run create webhook event
{ {
env.SendCheckRunEvent("test/valid", "pending", "created") env.SendCheckRunEvent("test", "valid", "pending", "created")
ExpectRunnerSetsCountEventuallyEquals(ctx, ns.Name, 1, "runner sets after webhook") ExpectRunnerSetsCountEventuallyEquals(ctx, ns.Name, 1, "runner sets after webhook")
ExpectRunnerSetsManagedReplicasCountEventuallyEquals(ctx, ns.Name, 4, "runners after first webhook event") ExpectRunnerSetsManagedReplicasCountEventuallyEquals(ctx, ns.Name, 4, "runners after first webhook event")
} }
@ -397,7 +396,7 @@ var _ = Context("INTEGRATION: Inside of a new namespace", func() {
// Scale-up to 5 replicas on second check_run create webhook event // Scale-up to 5 replicas on second check_run create webhook event
{ {
env.SendCheckRunEvent("test/valid", "pending", "created") env.SendCheckRunEvent("test", "valid", "pending", "created")
ExpectRunnerSetsManagedReplicasCountEventuallyEquals(ctx, ns.Name, 5, "runners after second webhook event") ExpectRunnerSetsManagedReplicasCountEventuallyEquals(ctx, ns.Name, 5, "runners after second webhook event")
} }
@ -420,9 +419,7 @@ func (env *testEnvironment) ExpectRegisteredNumberCountEventuallyEquals(want int
time.Second*1, time.Millisecond*500).Should(Equal(want), optionalDescriptions...) time.Second*1, time.Millisecond*500).Should(Equal(want), optionalDescriptions...)
} }
func (env *testEnvironment) SendPullRequestEvent(repo string, branch string, action string) { func (env *testEnvironment) SendPullRequestEvent(org, repo, branch, action string) {
org := strings.Split(repo, "/")[0]
resp, err := sendWebhook(env.webhookServer, "pull_request", &github.PullRequestEvent{ resp, err := sendWebhook(env.webhookServer, "pull_request", &github.PullRequestEvent{
PullRequest: &github.PullRequest{ PullRequest: &github.PullRequest{
Base: &github.PullRequestBranch{ Base: &github.PullRequestBranch{
@ -443,9 +440,7 @@ func (env *testEnvironment) SendPullRequestEvent(repo string, branch string, act
ExpectWithOffset(1, resp.StatusCode).To(Equal(200)) ExpectWithOffset(1, resp.StatusCode).To(Equal(200))
} }
func (env *testEnvironment) SendCheckRunEvent(repo string, status string, action string) { func (env *testEnvironment) SendCheckRunEvent(org, repo, status, action string) {
org := strings.Split(repo, "/")[0]
resp, err := sendWebhook(env.webhookServer, "check_run", &github.CheckRunEvent{ resp, err := sendWebhook(env.webhookServer, "check_run", &github.CheckRunEvent{
CheckRun: &github.CheckRun{ CheckRun: &github.CheckRun{
Status: github.String(status), Status: github.String(status),