blob: 938a00307371fdb46cd16dd93f94bb197b45efc9 [file] [log] [blame]
// Copyright 2020 The LUCI Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// Package pollertest provides test helpers for Gerrit Poller.
package pollertest
import (
"go.chromium.org/luci/server/tq/tqtesting"
"go.chromium.org/luci/cv/internal/gerrit/poller/task"
)
// PFilter returns payloads of Gerrit Poller tasks.
func PFilter(in tqtesting.TaskList) (out []*task.PollGerritTask) {
for _, t := range in.SortByETA() {
if t.Class == task.ClassID {
out = append(out, t.Payload.(*task.PollGerritTask))
}
}
return
}
// Projects filters tasks to only Gerrit Poller ones and returns their LUCI
// projects.
func Projects(in tqtesting.TaskList) []string {
out := PFilter(in)
ret := make([]string, len(out))
for i, p := range out {
ret[i] = p.GetLuciProject()
}
return ret
}