()
| 1000 | |
| 1001 | #[tokio::test] |
| 1002 | async fn create_vote_pr_success() { |
| 1003 | let event = setup_test_pr_event(); |
| 1004 | let create_vote_input = CreateVoteInput::new(None, &Event::PullRequest(event)); |
| 1005 | let cfg = CfgProfile { |
| 1006 | duration: Duration::from_secs(300), |
| 1007 | pass_threshold: 50.0, |
| 1008 | allowed_voters: Some(AllowedVoters::default()), |
| 1009 | ..Default::default() |
| 1010 | }; |
| 1011 | |
| 1012 | let mut db = MockDB::new(); |
| 1013 | db.expect_has_vote_open() |
| 1014 | .with(eq(REPOFN), eq(ISSUE_NUM)) |
| 1015 | .times(1) |
| 1016 | .returning(|_, _| Box::pin(future::ready(Ok(false)))); |
| 1017 | let cfg_copy = cfg.clone(); |
| 1018 | let create_vote_input_copy = create_vote_input.clone(); |
| 1019 | db.expect_store_vote() |
| 1020 | .withf(move |vote_comment_id, input, cfg| { |
| 1021 | *vote_comment_id == COMMENT_ID && *input == create_vote_input_copy && *cfg == cfg_copy |
| 1022 | }) |
| 1023 | .times(1) |
| 1024 | .returning(|_, _, _| Box::pin(future::ready(Ok(Uuid::new_v4())))); |
| 1025 | let mut gh = MockGH::new(); |
| 1026 | gh.expect_get_config_file() |
| 1027 | .with(eq(INST_ID), eq(ORG), eq(REPO)) |
| 1028 | .times(1) |
| 1029 | .returning(|_, _, _| Box::pin(future::ready(Some(get_test_valid_config())))); |
| 1030 | gh.expect_user_is_collaborator() |
| 1031 | .with(eq(INST_ID), eq(ORG), eq(REPO), eq(USER)) |
| 1032 | .times(1) |
| 1033 | .returning(|_, _, _, _| Box::pin(future::ready(Ok(true)))); |
| 1034 | let create_vote_input_copy = create_vote_input.clone(); |
| 1035 | gh.expect_post_comment() |
| 1036 | .withf(move |inst_id, owner, repo, issue_number, body| { |
| 1037 | let expected_body = tmpl::VoteCreated::new(&create_vote_input_copy, &cfg).render().unwrap(); |
| 1038 | *inst_id == INST_ID |
| 1039 | && owner == ORG |
| 1040 | && repo == REPO |
| 1041 | && *issue_number == ISSUE_NUM |
| 1042 | && body == expected_body.as_str() |
| 1043 | }) |
| 1044 | .times(1) |
| 1045 | .returning(|_, _, _, _, _| Box::pin(future::ready(Ok(COMMENT_ID)))); |
| 1046 | gh.expect_create_check_run() |
| 1047 | .with( |
| 1048 | eq(INST_ID), |
| 1049 | eq(ORG), |
| 1050 | eq(REPO), |
| 1051 | eq(ISSUE_NUM), |
| 1052 | eq(CheckDetails { |
| 1053 | status: "in_progress".to_string(), |
| 1054 | conclusion: None, |
| 1055 | summary: "Vote open".to_string(), |
| 1056 | }), |
| 1057 | ) |
| 1058 | .times(1) |
| 1059 | .returning(|_, _, _, _, _| Box::pin(future::ready(Ok(())))); |
nothing calls this directly
no test coverage detected