| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package analyzer | 5 package analyzer |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "fmt" | 8 "fmt" |
| 9 "infra/libs/testing/ansidiff" | 9 "infra/libs/testing/ansidiff" |
| 10 "infra/monitoring/client" | 10 "infra/monitoring/client" |
| (...skipping 1082 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1093 } | 1093 } |
| 1094 if gotErr != test.wantErr { | 1094 if gotErr != test.wantErr { |
| 1095 t.Errorf("%s failed. Got %s, want %s.", test.name, gotEr
r, test.wantErr) | 1095 t.Errorf("%s failed. Got %s, want %s.", test.name, gotEr
r, test.wantErr) |
| 1096 } | 1096 } |
| 1097 } | 1097 } |
| 1098 } | 1098 } |
| 1099 | 1099 |
| 1100 func TestExcludeFailure(t *testing.T) { | 1100 func TestExcludeFailure(t *testing.T) { |
| 1101 tests := []struct { | 1101 tests := []struct { |
| 1102 name string | 1102 name string |
| 1103 » » cfgs map[string]messages.MasterConfig | 1103 » » gk messages.GatekeeperConfig |
| 1104 master, builder, step string | 1104 master, builder, step string |
| 1105 want bool | 1105 want bool |
| 1106 }{ | 1106 }{ |
| 1107 { | 1107 { |
| 1108 name: "empty config", | 1108 name: "empty config", |
| 1109 master: "fake.master", | 1109 master: "fake.master", |
| 1110 builder: "fake.builder", | 1110 builder: "fake.builder", |
| 1111 step: "fake_step", | 1111 step: "fake_step", |
| 1112 want: false, | 1112 want: false, |
| 1113 }, | 1113 }, |
| 1114 { | 1114 { |
| 1115 name: "specifically excluded builder", | 1115 name: "specifically excluded builder", |
| 1116 master: "fake.master", | 1116 master: "fake.master", |
| 1117 builder: "fake.builder", | 1117 builder: "fake.builder", |
| 1118 step: "fake_step", | 1118 step: "fake_step", |
| 1119 » » » cfgs: map[string]messages.MasterConfig{ | 1119 » » » gk: messages.GatekeeperConfig{Masters: map[string][]mess
ages.MasterConfig{ |
| 1120 » » » » "fake.master": { | 1120 » » » » "fake.master": {{ |
| 1121 ExcludedBuilders: []string{"fake.builder
"}, | 1121 ExcludedBuilders: []string{"fake.builder
"}, |
| 1122 » » » » }, | 1122 » » » » }}, |
| 1123 » » » }, | 1123 » » » }}, |
| 1124 want: true, | 1124 want: true, |
| 1125 }, | 1125 }, |
| 1126 { | 1126 { |
| 1127 name: "specifically excluded master step", | 1127 name: "specifically excluded master step", |
| 1128 master: "fake.master", | 1128 master: "fake.master", |
| 1129 builder: "fake.builder", | 1129 builder: "fake.builder", |
| 1130 step: "fake_step", | 1130 step: "fake_step", |
| 1131 » » » cfgs: map[string]messages.MasterConfig{ | 1131 » » » gk: messages.GatekeeperConfig{Masters: map[string][]mess
ages.MasterConfig{ |
| 1132 » » » » "fake.master": { | 1132 » » » » "fake.master": {{ |
| 1133 ExcludedSteps: []string{"fake_step"}, | 1133 ExcludedSteps: []string{"fake_step"}, |
| 1134 » » » » }, | 1134 » » » » }}, |
| 1135 » » » }, | 1135 » » » }}, |
| 1136 want: true, | 1136 want: true, |
| 1137 }, | 1137 }, |
| 1138 { | 1138 { |
| 1139 name: "specifically excluded builder step", | 1139 name: "specifically excluded builder step", |
| 1140 master: "fake.master", | 1140 master: "fake.master", |
| 1141 builder: "fake.builder", | 1141 builder: "fake.builder", |
| 1142 step: "fake_step", | 1142 step: "fake_step", |
| 1143 » » » cfgs: map[string]messages.MasterConfig{ | 1143 » » » gk: messages.GatekeeperConfig{Masters: map[string][]mess
ages.MasterConfig{ |
| 1144 » » » » "fake.master": { | 1144 » » » » "fake.master": {{ |
| 1145 Builders: map[string]messages.BuilderCon
fig{ | 1145 Builders: map[string]messages.BuilderCon
fig{ |
| 1146 "fake.builder": { | 1146 "fake.builder": { |
| 1147 ExcludedSteps: []string{
"fake_step"}, | 1147 ExcludedSteps: []string{
"fake_step"}, |
| 1148 }, | 1148 }, |
| 1149 » » » » » }, | 1149 » » » » » }}, |
| 1150 » » » » }, | 1150 » » » » }}, |
| 1151 }, | 1151 }, |
| 1152 want: true, | 1152 want: true, |
| 1153 }, | 1153 }, |
| 1154 { | 1154 { |
| 1155 name: "wildcard builder excluded", | 1155 name: "wildcard builder excluded", |
| 1156 master: "fake.master", | 1156 master: "fake.master", |
| 1157 builder: "fake.builder", | 1157 builder: "fake.builder", |
| 1158 step: "fake_step", | 1158 step: "fake_step", |
| 1159 » » » cfgs: map[string]messages.MasterConfig{ | 1159 » » » gk: messages.GatekeeperConfig{Masters: map[string][]mess
ages.MasterConfig{ |
| 1160 » » » » "fake.master": { | 1160 » » » » "fake.master": {{ |
| 1161 ExcludedBuilders: []string{"*"}, | 1161 ExcludedBuilders: []string{"*"}, |
| 1162 » » » » }, | 1162 » » » » }}, |
| 1163 » » » }, | 1163 » » » }}, |
| 1164 want: true, | 1164 want: true, |
| 1165 }, | 1165 }, |
| 1166 } | 1166 } |
| 1167 | 1167 |
| 1168 a := New(&mockReader{}, 0, 10) | 1168 a := New(&mockReader{}, 0, 10) |
| 1169 for _, test := range tests { | 1169 for _, test := range tests { |
| 1170 » » a.MasterCfgs = test.cfgs | 1170 » » a.Gatekeeper = NewGatekeeperRules(test.gk) |
| 1171 » » got := a.excludeFailure(test.master, test.builder, test.step) | 1171 » » got := a.Gatekeeper.ExcludeFailure(test.master, test.builder, te
st.step) |
| 1172 if got != test.want { | 1172 if got != test.want { |
| 1173 t.Errorf("%s failed. Got: %+v, want: %+v", test.name, go
t, test.want) | 1173 t.Errorf("%s failed. Got: %+v, want: %+v", test.name, go
t, test.want) |
| 1174 } | 1174 } |
| 1175 } | 1175 } |
| 1176 } | 1176 } |
| OLD | NEW |