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
13e51d4e
Unverified
Commit
13e51d4e
authored
9 months ago
by
Ngoc Khuat
Committed by
GitHub
9 months ago
Browse files
Options
Downloads
Patches
Plain Diff
add mt/inbox as testing context for test helpers' (#43731)
parent
74e524c0
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/pulse_test.clj
+31
-32
31 additions, 32 deletions
test/metabase/pulse_test.clj
with
31 additions
and
32 deletions
test/metabase/pulse_test.clj
+
31
−
32
View file @
13e51d4e
...
...
@@ -105,24 +105,25 @@
:when
f
]
(
assert
(
fn?
f
))
(
testing
(
format
"sent to %s channel"
channel-type
)
(
mt/with-temp
[
Card
{
card-id
:id
}
(
merge
{
:name
pulse.test-util/card-name
:display
(
or
display
:line
)}
card
)]
(
with-pulse-for-card
[{
pulse-id
:id
}
{
:card
card-id
:pulse
pulse
:pulse-card
pulse-card
:channel
channel-type
}]
(
letfn
[(
thunk*
[]
(
f
{
:card-id
card-id,
:pulse-id
pulse-id
}
(
metabase.pulse/send-pulse!
(
pulse/retrieve-notification
pulse-id
))))
(
thunk
[]
(
if
fixture
(
fixture
{
:card-id
card-id,
:pulse-id
pulse-id
}
thunk*
)
(
thunk*
)))]
(
case
channel-type
:email
(
pulse.test-util/email-test-setup
(
thunk
))
:slack
(
pulse.test-util/slack-test-setup
(
thunk
)))))))))
(
testing
(
when
(
=
:email
channel-type
)
@
mt/inbox
)
(
mt/with-temp
[
Card
{
card-id
:id
}
(
merge
{
:name
pulse.test-util/card-name
:display
(
or
display
:line
)}
card
)]
(
with-pulse-for-card
[{
pulse-id
:id
}
{
:card
card-id
:pulse
pulse
:pulse-card
pulse-card
:channel
channel-type
}]
(
letfn
[(
thunk*
[]
(
f
{
:card-id
card-id,
:pulse-id
pulse-id
}
(
metabase.pulse/send-pulse!
(
pulse/retrieve-notification
pulse-id
))))
(
thunk
[]
(
if
fixture
(
fixture
{
:card-id
card-id,
:pulse-id
pulse-id
}
thunk*
)
(
thunk*
)))]
(
case
channel-type
:email
(
pulse.test-util/email-test-setup
(
thunk
))
:slack
(
pulse.test-util/slack-test-setup
(
thunk
))))))))))
(
defn-
tests
"Convenience for writing multiple tests using `do-test`. `common` is a map of shared properties as passed to `do-test`
...
...
@@ -394,16 +395,15 @@
:assert
{
:email
(
fn
[
_
_
]
(
testing
@
mt/inbox
(
is
(
=
(
into
{}
(
map
(
fn
[
user-kwd
]
(
mt/email-to
user-kwd
{
:subject
"Pulse: Pulse Name"
:bcc
#
{
"rasta@metabase.com"
"crowberto@metabase.com"
}
:body
[{
"Pulse Name"
true
}
pulse.test-util/png-attachment
pulse.test-util/png-attachment
]
:bcc?
true
}))
[
:rasta
:crowberto
]))
(
mt/summarize-multipart-email
#
"Pulse Name"
)))))}})))
(
is
(
=
(
into
{}
(
map
(
fn
[
user-kwd
]
(
mt/email-to
user-kwd
{
:subject
"Pulse: Pulse Name"
:bcc
#
{
"rasta@metabase.com"
"crowberto@metabase.com"
}
:body
[{
"Pulse Name"
true
}
pulse.test-util/png-attachment
pulse.test-util/png-attachment
]
:bcc?
true
}))
[
:rasta
:crowberto
]))
(
mt/summarize-multipart-email
#
"Pulse Name"
))))}})))
(
deftest
two-cards-in-one-pulse-test
(
testing
"1 pulse that has 2 cards, should contain two query image attachments (as well as an icon attachment)"
...
...
@@ -619,10 +619,9 @@
:assert
{
:email
(
fn
[
_
_
]
(
testing
@
mt/inbox
(
is
(
=
(
rasta-alert-email
"Alert: Test card has reached its goal"
[
test-card-result
pulse.test-util/png-attachment
pulse.test-util/png-attachment
])
(
mt/summarize-multipart-email
test-card-regex
)))))}})))
(
is
(
=
(
rasta-alert-email
"Alert: Test card has reached its goal"
[
test-card-result
pulse.test-util/png-attachment
pulse.test-util/png-attachment
])
(
mt/summarize-multipart-email
test-card-regex
))))}})))
(
deftest
below-goal-alert-test
(
testing
"Below goal alert"
...
...
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