Skip to content

Commit a2c03b7

Browse files
committed
sentry - middleware - campaign - improve tests
1 parent fed9616 commit a2c03b7

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

sentry/src/middleware/campaign.rs

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ mod test {
108108
use tower::Service;
109109

110110
use adapter::Dummy;
111-
use primitives::{test_util::DUMMY_CAMPAIGN, Campaign, ChainOf};
111+
use primitives::{test_util::CAMPAIGNS, Campaign, ChainOf};
112112

113113
use crate::{
114114
db::{insert_campaign, insert_channel},
@@ -130,7 +130,7 @@ mod test {
130130
.expect("Should build Request")
131131
};
132132

133-
let campaign = DUMMY_CAMPAIGN.clone();
133+
let campaign_context = CAMPAIGNS[0].clone();
134134

135135
async fn handle(
136136
Extension(campaign_context): Extension<ChainOf<Campaign>>,
@@ -147,7 +147,7 @@ mod test {
147147

148148
// bad CampaignId
149149
{
150-
let mut request = build_request(campaign.id);
150+
let mut request = build_request(campaign_context.context.id);
151151
*request.uri_mut() = "/WrongCampaignId".parse().unwrap();
152152

153153
let response = router
@@ -162,9 +162,9 @@ mod test {
162162
);
163163
}
164164

165-
// non-existent campaign
165+
// non-existent Campaign
166166
{
167-
let request = build_request(campaign.id);
167+
let request = build_request(campaign_context.context.id);
168168

169169
let response = router
170170
.call(request)
@@ -176,21 +176,18 @@ mod test {
176176

177177
// existing Campaign
178178
{
179-
let channel_chain = app
180-
.config
181-
.find_chain_of(DUMMY_CAMPAIGN.channel.token)
182-
.expect("Channel token should be whitelisted in config!");
183-
let channel_context = channel_chain.with_channel(DUMMY_CAMPAIGN.channel);
179+
let channel_context = campaign_context.of_channel();
180+
184181
// insert Channel
185182
insert_channel(&app.pool, &channel_context)
186183
.await
187184
.expect("Should insert Channel");
188185
// insert Campaign
189-
assert!(insert_campaign(&app.pool, &campaign)
186+
assert!(insert_campaign(&app.pool, &campaign_context.context)
190187
.await
191188
.expect("Should insert Campaign"));
192189

193-
let request = build_request(campaign.id);
190+
let request = build_request(campaign_context.context.id);
194191

195192
let response = router
196193
.call(request)

0 commit comments

Comments
 (0)