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

Function TestMsgPipeline_RcptModifier_Multiple

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

Source from the content-addressed store, hash-verified

370}
371
372func TestMsgPipeline_RcptModifier_Multiple(t *testing.T) {
373 target := testutils.Target{}
374 mod1, mod2 := testutils.Modifier{
375 InstName: "first_modifier",
376 RcptTo: map[string][]string{
377 "rcpt1@example.com": []string{"rcpt1-alias@example.com"},
378 "rcpt2@example.com": []string{"rcpt2-alias@example.com"},
379 },
380 }, testutils.Modifier{
381 InstName: "second_modifier",
382 RcptTo: map[string][]string{
383 "rcpt1-alias@example.com": []string{"rcpt1-alias2@example.com"},
384 "rcpt2@example.com": []string{"wtf@example.com"},
385 },
386 }
387 d := MsgPipeline{
388 msgpipelineCfg: msgpipelineCfg{
389 globalModifiers: modify.Group{
390 Modifiers: []module.Modifier{mod1, mod2},
391 },
392 perSource: map[string]sourceBlock{},
393 defaultSource: sourceBlock{
394 perRcpt: map[string]*rcptBlock{},
395 defaultRcpt: &rcptBlock{
396 targets: []module.DeliveryTarget{&target},
397 },
398 },
399 },
400 Log: testutils.Logger(t, "msgpipeline"),
401 }
402
403 testutils.DoTestDelivery(t, &d, "sender@example.com", []string{"rcpt1@example.com", "rcpt2@example.com"})
404
405 if len(target.Messages) != 1 {
406 t.Fatalf("wrong amount of messages received, want %d, got %d", 1, len(target.Messages))
407 }
408
409 testutils.CheckTestMessage(t, &target, 0, "sender@example.com", []string{"rcpt1-alias2@example.com", "rcpt2-alias@example.com"})
410
411 if mod1.UnclosedStates != 0 || mod2.UnclosedStates != 0 {
412 t.Fatalf("modifier state objects leak or double-closed, counter: %d, %d", mod1.UnclosedStates, mod2.UnclosedStates)
413 }
414}
415
416func TestMsgPipeline_RcptModifier_PreDispatch(t *testing.T) {
417 target := testutils.Target{}

Callers

nothing calls this directly

Calls 3

LoggerFunction · 0.92
DoTestDeliveryFunction · 0.92
CheckTestMessageFunction · 0.92

Tested by

no test coverage detected