Skip to content

Commit

Permalink
Add unit tests for new DefaultDecorationConfigs format.
Browse files Browse the repository at this point in the history
  • Loading branch information
cjwagner committed Feb 10, 2021
1 parent 407ac10 commit 49de076
Show file tree
Hide file tree
Showing 2 changed files with 652 additions and 7 deletions.
7 changes: 3 additions & 4 deletions prow/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -1392,14 +1392,14 @@ func setPeriodicDecorationDefaults(c *Config, ps *Periodic) {

// defaultPresubmits defaults the presubmits for one repo
func defaultPresubmits(presubmits []Presubmit, c *Config, repo string) error {
c.defaultPresubmitFields(presubmits)
var errs []error
for idx, ps := range presubmits {
setPresubmitDecorationDefaults(c, &presubmits[idx], repo)
if err := resolvePresets(ps.Name, ps.Labels, ps.Spec, c.Presets); err != nil {
errs = append(errs, err)
}
}
c.defaultPresubmitFields(presubmits)
if err := SetPresubmitRegexes(presubmits); err != nil {
errs = append(errs, fmt.Errorf("could not set regex: %v", err))
}
Expand All @@ -1409,14 +1409,14 @@ func defaultPresubmits(presubmits []Presubmit, c *Config, repo string) error {

// defaultPostsubmits defaults the postsubmits for one repo
func defaultPostsubmits(postsubmits []Postsubmit, c *Config, repo string) error {
c.defaultPostsubmitFields(postsubmits)
var errs []error
for idx, ps := range postsubmits {
setPostsubmitDecorationDefaults(c, &postsubmits[idx], repo)
if err := resolvePresets(ps.Name, ps.Labels, ps.Spec, c.Presets); err != nil {
errs = append(errs, err)
}
}
c.defaultPostsubmitFields(postsubmits)
if err := SetPostsubmitRegexes(postsubmits); err != nil {
errs = append(errs, fmt.Errorf("could not set regex: %v", err))
}
Expand All @@ -1425,15 +1425,14 @@ func defaultPostsubmits(postsubmits []Postsubmit, c *Config, repo string) error

// defaultPeriodics defaults c.Periodics
func defaultPeriodics(c *Config) error {
c.defaultPeriodicFields(c.Periodics)
var errs []error

for i := range c.Periodics {
setPeriodicDecorationDefaults(c, &c.Periodics[i])
if err := resolvePresets(c.Periodics[i].Name, c.Periodics[i].Labels, c.Periodics[i].Spec, c.Presets); err != nil {
errs = append(errs, err)
}
}
c.defaultPeriodicFields(c.Periodics)
return utilerrors.NewAggregate(errs)
}

Expand Down
Loading

0 comments on commit 49de076

Please sign in to comment.