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

Function create_vote_success

src/processor.rs:911–999  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

909
910 #[tokio::test]
911 async fn create_vote_success() {
912 let event = setup_test_issue_event();
913 let create_vote_input = CreateVoteInput::new(None, &Event::Issue(event));
914 let cfg = CfgProfile {
915 duration: Duration::from_secs(300),
916 pass_threshold: 50.0,
917 allowed_voters: Some(AllowedVoters::default()),
918 ..Default::default()
919 };
920
921 let mut db = MockDB::new();
922 db.expect_has_vote_open()
923 .with(eq(REPOFN), eq(ISSUE_NUM))
924 .times(1)
925 .returning(|_, _| Box::pin(future::ready(Ok(false))));
926 let cfg_copy = cfg.clone();
927 let create_vote_input_copy = create_vote_input.clone();
928 db.expect_store_vote()
929 .withf(move |vote_comment_id, input, cfg| {
930 *vote_comment_id == COMMENT_ID && *input == create_vote_input_copy && *cfg == cfg_copy
931 })
932 .times(1)
933 .returning(|_, _, _| Box::pin(future::ready(Ok(Uuid::new_v4()))));
934 let mut gh = MockGH::new();
935 gh.expect_get_config_file()
936 .with(eq(INST_ID), eq(ORG), eq(REPO))
937 .times(1)
938 .returning(|_, _, _| Box::pin(future::ready(Some(get_test_valid_config()))));
939 gh.expect_user_is_collaborator()
940 .with(eq(INST_ID), eq(ORG), eq(REPO), eq(USER))
941 .times(1)
942 .returning(|_, _, _, _| Box::pin(future::ready(Ok(true))));
943 let create_vote_input_copy = create_vote_input.clone();
944 gh.expect_post_comment()
945 .withf(move |inst_id, owner, repo, issue_number, body| {
946 let expected_body = tmpl::VoteCreated::new(&create_vote_input_copy, &cfg).render().unwrap();
947 *inst_id == INST_ID
948 && owner == ORG
949 && repo == REPO
950 && *issue_number == ISSUE_NUM
951 && body == expected_body.as_str()
952 })
953 .times(1)
954 .returning(|_, _, _, _, _| Box::pin(future::ready(Ok(COMMENT_ID))));
955 gh.expect_remove_label()
956 .with(
957 eq(INST_ID),
958 eq(ORG),
959 eq(REPO),
960 eq(ISSUE_NUM),
961 eq(VOTE_CLOSED_LABEL),
962 )
963 .times(1)
964 .returning(|_, _, _, _, _| Box::pin(future::ready(Ok(()))));
965 gh.expect_remove_label()
966 .with(
967 eq(INST_ID),
968 eq(ORG),

Callers

nothing calls this directly

Calls 4

setup_test_issue_eventFunction · 0.85
IssueClass · 0.85
get_test_valid_configFunction · 0.85
create_voteMethod · 0.80

Tested by

no test coverage detected