@@ -983,6 +983,46 @@ func TestHandleEvent(t *testing.T) {
983983 initialLabels : []string {"Meh" },
984984 expectedLabels : []string {"Meh" , "Test" },
985985 },
986+ {
987+ event : "issues" ,
988+ payloads : []string {"issue_open" },
989+ name : "Add a label to issue when author is in team" ,
990+ config : LabelerConfigV1 {
991+ Version : 1 ,
992+ Labels : []LabelMatcher {
993+ {
994+ Label : "ShouldAppear" ,
995+ AuthorInTeam : "team-with-srvaroa" ,
996+ },
997+ {
998+ Label : "ShouldNotAppear" ,
999+ AuthorInTeam : "team-with" ,
1000+ },
1001+ },
1002+ },
1003+ initialLabels : []string {"Meh" },
1004+ expectedLabels : []string {"Meh" , "ShouldAppear" },
1005+ },
1006+ {
1007+ event : "pull_request" ,
1008+ payloads : []string {"create_pr" },
1009+ name : "Add a label to PR when author is in team" ,
1010+ config : LabelerConfigV1 {
1011+ Version : 1 ,
1012+ Labels : []LabelMatcher {
1013+ {
1014+ Label : "ShouldAppear" ,
1015+ AuthorInTeam : "team-with-srvaroa" ,
1016+ },
1017+ {
1018+ Label : "ShouldNotAppear" ,
1019+ AuthorInTeam : "team-with" ,
1020+ },
1021+ },
1022+ },
1023+ initialLabels : []string {"Meh" },
1024+ expectedLabels : []string {"Meh" , "ShouldAppear" },
1025+ },
9861026 }
9871027
9881028 for _ , tc := range testCases {
@@ -1034,6 +1074,10 @@ func NewTestLabeler(t *testing.T, tc TestCase) Labeler {
10341074 data , err := ioutil .ReadAll (file )
10351075 return string (data ), nil
10361076 },
1077+ // Will return true whenever team contains the given user name
1078+ IsUserMemberOfTeam : func (user , team string ) (bool , error ) {
1079+ return strings .Contains (team , user ), nil
1080+ },
10371081 },
10381082 }
10391083}
0 commit comments