@@ -833,6 +833,16 @@ func TestMatchPipelinerunByAnnotation(t *testing.T) {
833833 },
834834 }
835835
836+ pipelineWithSlashInBranchName := & tektonv1.PipelineRun {
837+ ObjectMeta : metav1.ObjectMeta {
838+ Name : "pipeline-withslashesinbranch" ,
839+ Annotations : map [string ]string {
840+ keys .OnEvent : "[pull_request, push]" ,
841+ keys .OnTargetBranch : "[test/main]" ,
842+ },
843+ },
844+ }
845+
836846 pipelineRefAll := & tektonv1.PipelineRun {
837847 ObjectMeta : metav1.ObjectMeta {
838848 Name : "pipeline-other" ,
@@ -1061,21 +1071,37 @@ func TestMatchPipelinerunByAnnotation(t *testing.T) {
10611071 wantErr : false ,
10621072 },
10631073 {
1064- name : "not- match-push-branch-matching " ,
1074+ name : "branch-matching-doesnot- match-for- push-event " ,
10651075 args : args {
10661076 runevent : info.Event {TriggerTarget : "push" , EventType : "push" , BaseBranch : "refs/heads/someothername/then/main" },
10671077 pruns : []* tektonv1.PipelineRun {pipelineGood , pipelinePush },
10681078 },
10691079 wantErr : true ,
10701080 },
10711081 {
1072- name : "not- match-pull-request-branch-matching " ,
1082+ name : "branch-matching-doesnot- match-for- pull-request" ,
10731083 args : args {
10741084 runevent : info.Event {TriggerTarget : "pull_request" , EventType : "pull_request" , BaseBranch : "someothername/then/main" },
10751085 pruns : []* tektonv1.PipelineRun {pipelineGood , pipelinePush },
10761086 },
10771087 wantErr : true ,
10781088 },
1089+ {
1090+ name : "branch-matching-match-for-push-when-there-are-slashes-in-between-branch-name" ,
1091+ args : args {
1092+ runevent : info.Event {TriggerTarget : "push" , EventType : "push" , BaseBranch : "refs/heads/test/main" },
1093+ pruns : []* tektonv1.PipelineRun {pipelineWithSlashInBranchName },
1094+ },
1095+ wantErr : false ,
1096+ },
1097+ {
1098+ name : "branch-matching-match-for-pull_request-when-there-are-slashes-in-between-branch-name" ,
1099+ args : args {
1100+ runevent : info.Event {TriggerTarget : "pull_request" , EventType : "pull_request" , BaseBranch : "refs/heads/test/main" },
1101+ pruns : []* tektonv1.PipelineRun {pipelineWithSlashInBranchName },
1102+ },
1103+ wantErr : false ,
1104+ },
10791105 }
10801106
10811107 for _ , tt := range tests {
0 commit comments