(t *testing.T)
| 270 | } |
| 271 | |
| 272 | func TestMsgPipeline_SourceCheck_Errors(t *testing.T) { |
| 273 | target := testutils.Target{} |
| 274 | check_ := testutils.Check{ |
| 275 | InitErr: errors.New("1"), |
| 276 | ConnRes: module.CheckResult{Reject: true, Reason: errors.New("2")}, |
| 277 | SenderRes: module.CheckResult{Reject: true, Reason: errors.New("3")}, |
| 278 | RcptRes: module.CheckResult{Reject: true, Reason: errors.New("4")}, |
| 279 | BodyRes: module.CheckResult{Reject: true, Reason: errors.New("5")}, |
| 280 | } |
| 281 | globalCheck := testutils.Check{} |
| 282 | d := MsgPipeline{ |
| 283 | msgpipelineCfg: msgpipelineCfg{ |
| 284 | globalChecks: []module.Check{&globalCheck}, |
| 285 | perSource: map[string]sourceBlock{}, |
| 286 | defaultSource: sourceBlock{ |
| 287 | perRcpt: map[string]*rcptBlock{}, |
| 288 | checks: []module.Check{&check_}, |
| 289 | defaultRcpt: &rcptBlock{ |
| 290 | targets: []module.DeliveryTarget{&target}, |
| 291 | }, |
| 292 | }, |
| 293 | }, |
| 294 | Hostname: "TEST-HOST", |
| 295 | Log: testutils.Logger(t, "msgpipeline"), |
| 296 | } |
| 297 | |
| 298 | t.Run("init err", func(t *testing.T) { |
| 299 | _, err := testutils.DoTestDeliveryErr(t, &d, "sender@example.com", []string{"rcpt1@example.com", "rcpt2@example.com"}) |
| 300 | if err == nil { |
| 301 | t.Fatal("expected error") |
| 302 | } |
| 303 | }) |
| 304 | |
| 305 | check_.InitErr = nil |
| 306 | |
| 307 | t.Run("conn err", func(t *testing.T) { |
| 308 | _, err := testutils.DoTestDeliveryErr(t, &d, "sender@example.com", []string{"rcpt1@example.com", "rcpt2@example.com"}) |
| 309 | if err == nil { |
| 310 | t.Fatal("expected error") |
| 311 | } |
| 312 | }) |
| 313 | |
| 314 | check_.ConnRes.Reject = false |
| 315 | |
| 316 | t.Run("mail from err", func(t *testing.T) { |
| 317 | _, err := testutils.DoTestDeliveryErr(t, &d, "sender@example.com", []string{"rcpt1@example.com", "rcpt2@example.com"}) |
| 318 | if err == nil { |
| 319 | t.Fatal("expected error") |
| 320 | } |
| 321 | }) |
| 322 | |
| 323 | check_.SenderRes.Reject = false |
| 324 | |
| 325 | t.Run("rcpt to err", func(t *testing.T) { |
| 326 | _, err := testutils.DoTestDeliveryErr(t, &d, "sender@example.com", []string{"rcpt1@example.com", "rcpt2@example.com"}) |
| 327 | if err == nil { |
| 328 | t.Fatal("expected error") |
| 329 | } |
nothing calls this directly
no test coverage detected