Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Metabase
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Engineering Digital Service
Metabase
Commits
ec965c57
Unverified
Commit
ec965c57
authored
5 years ago
by
Daniel Higginbotham
Committed by
GitHub
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
minor test refactor (#11652)
convert messages_test to use clojure.test, simplify test a little
parent
2807015b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/metabase/email/messages_test.clj
+28
-35
28 additions, 35 deletions
test/metabase/email/messages_test.clj
with
28 additions
and
35 deletions
test/metabase/email/messages_test.clj
+
28
−
35
View file @
ec965c57
(
ns
metabase.email.messages-test
(
:require
[
expectations
:refer
[
expect
]
]
(
:require
[
clojure.test
:refer
:all
]
[
metabase.email-test
:as
email-test
]
[
metabase.email.messages
:as
messages
]
[
metabase.test.util
:as
tu
])
...
...
@@ -8,29 +8,29 @@
;; new user email
;; NOTE: we are not validating the content of the email body namely because it's got randomized elements and thus
;; it would be extremely hard to have a predictable test that we can rely on
(
expect
[{
:from
"notifications@metabase.com"
,
:to
[
"test@test.com"
]
,
:subject
"You're invited to join Metabase Test's Metabase"
,
:body
[{
:type
"text/html; charset=utf-8"
}]}]
(
tu/with-temporary-setting-values
[
site-name
"Metabase Test"
]
(
email-test/with-fake-inbox
(
messages/send-new-user-email!
{
:first_name
"test"
:email
"test@test.com"
}
{
:first_name
"invitor"
:email
"invited_by@test.com"
}
"http://localhost/some/url"
)
(
->
(
@
email-test/inbox
"test@test.com"
)
(
update-in
[
0
:body
0
]
dissoc
:content
)))))
(
deftest
new-user-email
(
is
(
=
[{
:from
"notifications@metabase.com"
,
:to
[
"test@test.com"
]
,
:subject
"You're invited to join Metabase Test's Metabase"
,
:body
[{
:type
"text/html; charset=utf-8"
}]}]
(
tu/with-temporary-setting-values
[
site-name
"Metabase Test"
]
(
email-test/with-fake-inbox
(
messages/send-new-user-email!
{
:first_name
"test"
:email
"test@test.com"
}
{
:first_name
"invitor"
:email
"invited_by@test.com"
}
"http://localhost/some/url"
)
(
->
(
@
email-test/inbox
"test@test.com"
)
(
update-in
[
0
:body
0
]
dissoc
:content
)))))
))
;; password reset email
(
expect
[{
:from
"notifications@metabase.com"
,
:to
[
"test@test.com"
]
,
:subject
"[Metabase] Password Reset Request"
,
:body
[{
:type
"text/html; charset=utf-8"
}]}]
(
email-test/with-fake-inbox
(
messages/send-password-reset-email!
"test@test.com"
(
not
:google-auth
)
"test.domain.com"
"http://localhost/some/url"
)
(
->
(
@
email-test/inbox
"test@test.com"
)
(
update-in
[
0
:body
0
]
dissoc
:content
))))
(
deftest
password-reset-email
(
is
(
=
[{
:from
"notifications@metabase.com"
,
:to
[
"test@test.com"
]
,
:subject
"[Metabase] Password Reset Request"
,
:body
[{
:type
"text/html; charset=utf-8"
}]}]
(
email-test/with-fake-inbox
(
messages/send-password-reset-email!
"test@test.com"
(
not
:google-auth
)
"test.domain.com"
"http://localhost/some/url"
)
(
->
(
@
email-test/inbox
"test@test.com"
)
(
update-in
[
0
:body
0
]
dissoc
:content
))))
))
(
defmacro
^
:private
with-create-temp-failure
[
&
body
]
`
(
with-redefs
[
messages/create-temp-file
(
fn
[
~
'_
]
...
...
@@ -38,16 +38,9 @@
~@
body
))
;; Test that IOException bubbles up
(
expect
IOException
(
with-create-temp-failure
(
#
'messages/create-temp-file-or-throw
"txt"
)))
;; When we fail to create the temp file, include the directory in the error message
(
expect
(
re-pattern
(
format
"Unable to create temp file in `%s`"
(
System/getProperty
"java.io.tmpdir"
)))
(
try
(
with-create-temp-failure
(
#
'messages/create-temp-file-or-throw
"txt"
))
(
catch
Exception
e
(
.getMessage
e
))))
(
deftest
throws-exception
(
is
(
thrown-with-msg?
IOException
(
re-pattern
(
format
"Unable to create temp file in `%s`"
(
System/getProperty
"java.io.tmpdir"
)))
(
with-create-temp-failure
(
#
'messages/create-temp-file-or-throw
"txt"
)))))
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment