MCPcopy Create free account
hub / github.com/foxcpp/maddy / TestMsgPipeline_GlobalModifier_Errors

Function TestMsgPipeline_GlobalModifier_Errors

internal/msgpipeline/modifier_test.go:513–578  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

511}
512
513func TestMsgPipeline_GlobalModifier_Errors(t *testing.T) {
514 target := testutils.Target{}
515 mod := testutils.Modifier{
516 InstName: "test_modifier",
517 InitErr: errors.New("1"),
518 MailFromErr: errors.New("2"),
519 RcptToErr: errors.New("3"),
520 BodyErr: errors.New("4"),
521 }
522 d := MsgPipeline{
523 msgpipelineCfg: msgpipelineCfg{
524 globalModifiers: modify.Group{Modifiers: []module.Modifier{&mod}},
525 perSource: map[string]sourceBlock{},
526 defaultSource: sourceBlock{
527 defaultRcpt: &rcptBlock{
528 targets: []module.DeliveryTarget{&target},
529 },
530 },
531 },
532 Log: testutils.Logger(t, "msgpipeline"),
533 }
534
535 t.Run("init err", func(t *testing.T) {
536 _, err := testutils.DoTestDeliveryErr(t, &d, "sender@example.com", []string{"rcpt1@example.com", "rcpt2@example.com"})
537 if err == nil {
538 t.Fatal("expected error")
539 }
540 })
541
542 mod.InitErr = nil
543
544 t.Run("mail from err", func(t *testing.T) {
545 _, err := testutils.DoTestDeliveryErr(t, &d, "sender@example.com", []string{"rcpt1@example.com", "rcpt2@example.com"})
546 if err == nil {
547 t.Fatal("expected error")
548 }
549 })
550
551 mod.MailFromErr = nil
552
553 t.Run("rcpt to err", func(t *testing.T) {
554 _, err := testutils.DoTestDeliveryErr(t, &d, "sender@example.com", []string{"rcpt1@example.com", "rcpt2@example.com"})
555 if err == nil {
556 t.Fatal("expected error")
557 }
558 })
559
560 mod.RcptToErr = nil
561
562 t.Run("body err", func(t *testing.T) {
563 _, err := testutils.DoTestDeliveryErr(t, &d, "sender@example.com", []string{"rcpt1@example.com", "rcpt2@example.com"})
564 if err == nil {
565 t.Fatal("expected error")
566 }
567 })
568
569 mod.BodyErr = nil
570

Callers

nothing calls this directly

Calls 4

LoggerFunction · 0.92
DoTestDeliveryErrFunction · 0.92
DoTestDeliveryFunction · 0.92
RunMethod · 0.45

Tested by

no test coverage detected