github.com/abayer/test-infra@v0.0.5/mungegithub/mungers/matchers/event/finder_test.go (about) 1 /* 2 Copyright 2016 The Kubernetes Authors. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package event 18 19 import ( 20 "reflect" 21 "testing" 22 23 "github.com/google/go-github/github" 24 ) 25 26 func makeEvent(event string) *github.IssueEvent { 27 return &github.IssueEvent{ 28 Event: &event, 29 } 30 } 31 32 func TestFilterEvents(t *testing.T) { 33 events := []*github.IssueEvent{ 34 makeEvent("1"), 35 makeEvent("2"), 36 makeEvent("3"), 37 makeEvent("4"), 38 } 39 40 emptyList := FilterEvents(events, False{}) 41 if len(emptyList) != 0 { 42 t.Error("False filter shouldn't match any element") 43 } 44 45 fullList := FilterEvents(events, True{}) 46 if !reflect.DeepEqual([]*github.IssueEvent(fullList), events) { 47 t.Error("True filter should match every element") 48 } 49 }