Skip to content

Commit

Permalink
add test cases about filter branch name wheter is invalid
Browse files Browse the repository at this point in the history
  • Loading branch information
xuwei committed Oct 26, 2021
1 parent 1f738ae commit c842524
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions pkg/kapis/devops/v1alpha3/pipeline/branch_filter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,27 @@ func Test_filterBranches(t *testing.T) {
Name: "main2",
PullRequest: &job.PullRequest{},
}},
}, {
name: "With filter: origin, but name is invalid",
args: args{
branches: []pipeline.Branch{{
Name: "main1",
PullRequest: nil,
}, {
Name: "主分支2",
PullRequest: &job.PullRequest{},
}, {
Name: "PR1",
PullRequest: &job.PullRequest{
ID: "1",
},
}},
filter: "origin",
},
want: []pipeline.Branch{{
Name: "main1",
PullRequest: nil,
}},
}, {
name: "With filter: pull-requests",
args: args{
Expand All @@ -86,6 +107,34 @@ func Test_filterBranches(t *testing.T) {
ID: "1",
},
}},
}, {
name: "With filter: pull-requests, but name is invalid",
args: args{
branches: []pipeline.Branch{{
Name: "main1",
PullRequest: nil,
}, {
Name: "main2",
PullRequest: &job.PullRequest{},
}, {
Name: "PR1",
PullRequest: &job.PullRequest{
ID: "1",
},
}, {
Name: "分支2",
PullRequest: &job.PullRequest{
ID: "2",
},
}},
filter: "pull-requests",
},
want: []pipeline.Branch{{
Name: "PR1",
PullRequest: &job.PullRequest{
ID: "1",
},
}},
}, {
name: "With other filter",
args: args{
Expand Down

0 comments on commit c842524

Please sign in to comment.