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

Function TestMsgPipeline_SenderModifier

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

Source from the content-addressed store, hash-verified

28)
29
30func TestMsgPipeline_SenderModifier(t *testing.T) {
31 target := testutils.Target{}
32 modifier := testutils.Modifier{
33 InstName: "test_modifier",
34 MailFrom: map[string]string{
35 "sender@example.com": "sender2@example.com",
36 },
37 }
38 d := MsgPipeline{
39 msgpipelineCfg: msgpipelineCfg{
40 globalModifiers: modify.Group{
41 Modifiers: []module.Modifier{modifier},
42 },
43 perSource: map[string]sourceBlock{},
44 defaultSource: sourceBlock{
45 perRcpt: map[string]*rcptBlock{},
46 defaultRcpt: &rcptBlock{
47 targets: []module.DeliveryTarget{&target},
48 },
49 },
50 },
51 Log: testutils.Logger(t, "msgpipeline"),
52 }
53
54 testutils.DoTestDelivery(t, &d, "sender@example.com", []string{"rcpt1@example.com", "rcpt2@example.com"})
55
56 if len(target.Messages) != 1 {
57 t.Fatalf("wrong amount of messages received, want %d, got %d", 1, len(target.Messages))
58 }
59
60 testutils.CheckTestMessage(t, &target, 0, "sender2@example.com", []string{"rcpt1@example.com", "rcpt2@example.com"})
61
62 if modifier.UnclosedStates != 0 {
63 t.Fatalf("modifier state objects leak or double-closed, counter: %d", modifier.UnclosedStates)
64 }
65}
66
67func TestMsgPipeline_SenderModifier_Multiple(t *testing.T) {
68 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