MCPcopy Create free account
hub / github.com/cncf/gitvote / check_vote_success

Function check_vote_success

src/processor.rs:1344–1394  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1342
1343 #[tokio::test]
1344 async fn check_vote_success() {
1345 let mut db = MockDB::new();
1346 db.expect_get_open_vote()
1347 .with(eq(REPOFN), eq(ISSUE_NUM))
1348 .times(1)
1349 .returning(|_, _| Box::pin(future::ready(Ok(Some(setup_test_vote())))));
1350 db.expect_update_vote_last_check()
1351 .with(eq(Uuid::parse_str(VOTE_ID).unwrap()))
1352 .times(1)
1353 .returning(|_| Box::pin(future::ready(Ok(()))));
1354 let mut gh = MockGH::new();
1355 gh.expect_get_comment_reactions()
1356 .with(eq(INST_ID), eq(ORG), eq(REPO), eq(COMMENT_ID))
1357 .times(1)
1358 .returning(|_, _, _, _| {
1359 Box::pin(future::ready(Ok(vec![Reaction {
1360 user: User {
1361 login: USER1.to_string(),
1362 },
1363 content: REACTION_IN_FAVOR.to_string(),
1364 created_at: TIMESTAMP.to_string(),
1365 }])))
1366 });
1367 gh.expect_get_allowed_voters()
1368 .withf(|inst_id, cfg, owner, repo, org| {
1369 *inst_id == INST_ID
1370 && *cfg == setup_test_vote().cfg
1371 && owner == ORG
1372 && repo == REPO
1373 && *org == Some(ORG.to_string()).as_ref()
1374 })
1375 .times(1)
1376 .returning(|_, _, _, _, _| Box::pin(future::ready(Ok(vec![USER1.to_string()]))));
1377 gh.expect_post_comment()
1378 .withf(|inst_id, owner, repo, issue_number, body| {
1379 let results = setup_test_vote_results();
1380 let expected_body = tmpl::VoteStatus::new(&results).render().unwrap();
1381 *inst_id == INST_ID
1382 && owner == ORG
1383 && repo == REPO
1384 && *issue_number == ISSUE_NUM
1385 && body == expected_body.as_str()
1386 })
1387 .times(1)
1388 .returning(|_, _, _, _, _| Box::pin(future::ready(Ok(COMMENT_ID))));
1389
1390 let (_, cmds_rx) = async_channel::unbounded();
1391 let event = setup_test_pr_event();
1392 let cmds_handler = CommandsHandler::new(Arc::new(db), Arc::new(gh), cmds_rx);
1393 cmds_handler.check_vote(&CheckVoteInput::new(&Event::PullRequest(event))).await.unwrap();
1394 }
1395
1396 #[tokio::test]
1397 #[should_panic(expected = "error closing finished vote")]

Callers

nothing calls this directly

Calls 5

setup_test_voteFunction · 0.85
setup_test_vote_resultsFunction · 0.85
setup_test_pr_eventFunction · 0.85
PullRequestClass · 0.85
check_voteMethod · 0.80

Tested by

no test coverage detected