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

Function TestMsgPipeline_RcptModifier

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

Source from the content-addressed store, hash-verified

231}
232
233func TestMsgPipeline_RcptModifier(t *testing.T) {
234 target := testutils.Target{}
235 mod := testutils.Modifier{
236 InstName: "test_modifier",
237 RcptTo: map[string][]string{
238 "rcpt1@example.com": []string{"rcpt1-alias@example.com"},
239 "rcpt2@example.com": []string{"rcpt2-alias@example.com"},
240 },
241 }
242 d := MsgPipeline{
243 msgpipelineCfg: msgpipelineCfg{
244 globalModifiers: modify.Group{
245 Modifiers: []module.Modifier{mod},
246 },
247 perSource: map[string]sourceBlock{},
248 defaultSource: sourceBlock{
249 perRcpt: map[string]*rcptBlock{},
250 defaultRcpt: &rcptBlock{
251 targets: []module.DeliveryTarget{&target},
252 },
253 },
254 },
255 Log: testutils.Logger(t, "msgpipeline"),
256 }
257
258 testutils.DoTestDelivery(t, &d, "sender@example.com", []string{"rcpt1@example.com", "rcpt2@example.com"})
259
260 if len(target.Messages) != 1 {
261 t.Fatalf("wrong amount of messages received, want %d, got %d", 1, len(target.Messages))
262 }
263
264 testutils.CheckTestMessage(t, &target, 0, "sender@example.com", []string{"rcpt1-alias@example.com", "rcpt2-alias@example.com"})
265
266 if mod.UnclosedStates != 0 {
267 t.Fatalf("modifier state objects leak or double-closed, counter: %d", mod.UnclosedStates)
268 }
269}
270
271func TestMsgPipeline_RcptModifier_OriginalRcpt(t *testing.T) {
272 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