MCPcopy
hub / github.com/pocketbase/pocketbase / TestAddressesToStrings

Function TestAddressesToStrings

tools/mailer/mailer_test.go:11–51  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

9)
10
11func TestAddressesToStrings(t *testing.T) {
12 t.Parallel()
13
14 scenarios := []struct {
15 withName bool
16 addresses []mail.Address
17 expected []string
18 }{
19 {
20 true,
21 []mail.Address{{Name: "John Doe", Address: "test1@example.com"}, {Name: "Jane Doe", Address: "test2@example.com"}},
22 []string{`"John Doe" <test1@example.com>`, `"Jane Doe" <test2@example.com>`},
23 },
24 {
25 true,
26 []mail.Address{{Name: "John Doe", Address: "test1@example.com"}, {Address: "test2@example.com"}},
27 []string{`"John Doe" <test1@example.com>`, `test2@example.com`},
28 },
29 {
30 false,
31 []mail.Address{{Name: "John Doe", Address: "test1@example.com"}, {Name: "Jane Doe", Address: "test2@example.com"}},
32 []string{`test1@example.com`, `test2@example.com`},
33 },
34 }
35
36 for _, s := range scenarios {
37 t.Run(fmt.Sprintf("%v_%v", s.withName, s.addresses), func(t *testing.T) {
38 result := addressesToStrings(s.addresses, s.withName)
39
40 if len(s.expected) != len(result) {
41 t.Fatalf("Expected\n%v\ngot\n%v", s.expected, result)
42 }
43
44 for k, v := range s.expected {
45 if v != result[k] {
46 t.Fatalf("Expected %d address %q, got %q", k, v, result[k])
47 }
48 }
49 })
50 }
51}
52
53func TestDetectReaderMimeType(t *testing.T) {
54 t.Parallel()

Callers

nothing calls this directly

Calls 2

addressesToStringsFunction · 0.85
RunMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…