(t *testing.T)
| 128 | } |
| 129 | |
| 130 | func TestSignMessage_EmptyDomainSkipsLookup(t *testing.T) { |
| 131 | // A pathological caller passing "" as the signing domain must |
| 132 | // short-circuit rather than calling GetDKIMKey(ctx, ""), which |
| 133 | // would scan all rows. Defensive guard at the entry point. |
| 134 | calls := 0 |
| 135 | lookup := &fakeDKIMLookup{ |
| 136 | get: func(_ context.Context, _ string) (string, []byte, error) { |
| 137 | calls++ |
| 138 | return "sel", []byte("not-a-real-key"), nil |
| 139 | }, |
| 140 | } |
| 141 | s := NewSenderWithDKIM(nil, "example.com", lookup) |
| 142 | _, ok := s.signMessage([]byte(validTestMessage), "") |
| 143 | if ok { |
| 144 | t.Errorf("ok = true, want false (empty domain)") |
| 145 | } |
| 146 | if calls != 0 { |
| 147 | t.Errorf("GetDKIMKey called %d times for empty domain, want 0", calls) |
| 148 | } |
| 149 | } |
| 150 | |
| 151 | func TestSignMessage_LookupErrorFailsOpen(t *testing.T) { |
| 152 | // DB transient error → log + proceed unsigned. The caller treats |
nothing calls this directly
no test coverage detected