(t *testing.T)
| 77 | } |
| 78 | |
| 79 | func TestSendRecordVerification(t *testing.T) { |
| 80 | t.Parallel() |
| 81 | |
| 82 | testApp, _ := tests.NewTestApp() |
| 83 | defer testApp.Cleanup() |
| 84 | |
| 85 | user, _ := testApp.FindFirstRecordByData("users", "email", "test@example.com") |
| 86 | |
| 87 | // to test that it is escaped |
| 88 | user.Set("name", "<p>"+user.GetString("name")+"</p>") |
| 89 | |
| 90 | err := mails.SendRecordVerification(testApp, user) |
| 91 | if err != nil { |
| 92 | t.Fatal(err) |
| 93 | } |
| 94 | |
| 95 | if testApp.TestMailer.TotalSend() != 1 { |
| 96 | t.Fatalf("Expected one email to be sent, got %d", testApp.TestMailer.TotalSend()) |
| 97 | } |
| 98 | |
| 99 | expectedParts := []string{ |
| 100 | html.EscapeString(user.GetString("name")) + "{RECORD:tokenKey}", // the record name as {RECORD:name} |
| 101 | "http://localhost:8090/_/#/auth/confirm-verification/eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.", |
| 102 | } |
| 103 | for _, part := range expectedParts { |
| 104 | if !strings.Contains(testApp.TestMailer.LastMessage().HTML, part) { |
| 105 | t.Fatalf("Couldn't find %s \nin\n %s", part, testApp.TestMailer.LastMessage().HTML) |
| 106 | } |
| 107 | } |
| 108 | } |
| 109 | |
| 110 | func TestSendRecordChangeEmail(t *testing.T) { |
| 111 | t.Parallel() |
nothing calls this directly
no test coverage detected
searching dependent graphs…