Skip to content

Commit 9c30b5d

Browse files
chmoueltheakshaypant
authored andcommitted
refactor: Rename github pull request test function
Renamed `TestGithubPullRequestSecondController` to `TestGithubSecondPullRequest` so the e2e runners categorize it as running on second controllers.
1 parent 7605c5a commit 9c30b5d

3 files changed

Lines changed: 27 additions & 23 deletions

File tree

hack/gh-workflow-ci.sh

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -78,31 +78,32 @@ get_tests() {
7878
all_tests=$(grep -hioP '^func[[:space:]]+Test[[:alnum:]_]+' "${testfiles[@]}" | sed -E 's/^func[[:space:]]+//')
7979

8080
case "${target}" in
81-
concurrency)
82-
printf '%s\n' "${all_tests}" | grep -iP 'Concurrency'
83-
;;
84-
github)
85-
printf '%s\n' "${all_tests}" | grep -iP 'Github' | grep -ivP 'Concurrency|GithubSecond|SecondController'
86-
;;
87-
github_second_controller)
88-
printf '%s\n' "${all_tests}" | grep -iP 'GithubSecond|SecondController' | grep -ivP 'Concurrency'
89-
;;
90-
gitlab_bitbucket)
91-
printf '%s\n' "${all_tests}" | grep -iP 'Gitlab|Bitbucket' | grep -ivP 'Concurrency'
92-
;;
93-
gitea_others)
94-
printf '%s\n' "${all_tests}" | grep -ivP 'Github|Gitlab|Bitbucket|Concurrency'
95-
;;
96-
*)
97-
echo "Invalid target: ${target}"
98-
echo "supported targets: github, github_second_controller, gitlab_bitbucket, gitea_others, concurrency"
99-
;;
81+
concurrency)
82+
printf '%s\n' "${all_tests}" | grep -iP 'Concurrency'
83+
;;
84+
github)
85+
printf '%s\n' "${all_tests}" | grep -iP 'Github' | grep -ivP 'Concurrency|GithubSecond'
86+
;;
87+
github_second_controller)
88+
printf '%s\n' "${all_tests}" | grep -iP 'GithubSecond' | grep -ivP 'Concurrency'
89+
;;
90+
gitlab_bitbucket)
91+
printf '%s\n' "${all_tests}" | grep -iP 'Gitlab|Bitbucket' | grep -ivP 'Concurrency'
92+
;;
93+
gitea_others)
94+
printf '%s\n' "${all_tests}" | grep -ivP 'Github|Gitlab|Bitbucket|Concurrency'
95+
;;
96+
*)
97+
echo "Invalid target: ${target}"
98+
echo "supported targets: github, github_second_controller, gitlab_bitbucket, gitea_others, concurrency"
99+
;;
100100
esac
101101
}
102102

103103
run_e2e_tests() {
104104
set +x
105105
target="${TEST_PROVIDER}"
106+
export PAC_E2E_KEEP_NS=true
106107

107108
mapfile -t tests < <(get_tests "${target}")
108109
echo "About to run ${#tests[@]} tests: ${tests[*]}"

test/github_pullrequest_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func TestGithubPullRequest(t *testing.T) {
4343
defer g.TearDown(ctx, t)
4444
}
4545

46-
func TestGithubPullRequestSecondController(t *testing.T) {
46+
func TestGithubSecondPullRequest(t *testing.T) {
4747
ctx := context.Background()
4848
g := &tgithub.PRTest{
4949
Label: "Github Rerequest",

test/pkg/repository/teardown.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package repository
22

33
import (
44
"context"
5+
"os"
56
"testing"
67

78
"github.com/openshift-pipelines/pipelines-as-code/pkg/params"
@@ -13,7 +14,9 @@ func NSTearDown(ctx context.Context, t *testing.T, runcnx *params.Run, targetNS
1314
runcnx.Clients.Log.Infof("Deleting Repository in %s", targetNS)
1415
err := runcnx.Clients.PipelineAsCode.PipelinesascodeV1alpha1().Repositories(targetNS).DeleteCollection(ctx, metav1.DeleteOptions{}, metav1.ListOptions{})
1516
assert.NilError(t, err)
16-
runcnx.Clients.Log.Infof("Deleting NS %s", targetNS)
17-
err = runcnx.Clients.Kube.CoreV1().Namespaces().Delete(ctx, targetNS, metav1.DeleteOptions{})
18-
assert.NilError(t, err)
17+
if os.Getenv("PAC_E2E_KEEP_NS") != "true" {
18+
runcnx.Clients.Log.Infof("Deleting NS %s", targetNS)
19+
err = runcnx.Clients.Kube.CoreV1().Namespaces().Delete(ctx, targetNS, metav1.DeleteOptions{})
20+
assert.NilError(t, err)
21+
}
1922
}

0 commit comments

Comments
 (0)