1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
use crate::jcli::command::rest::v1::VoteCommand;
use assert_cmd::assert::OutputAssertExt;
use jortestkit::prelude::ProcessOutput;

pub struct Vote {
    vote_command: VoteCommand,
}

impl Vote {
    pub fn new(vote_command: VoteCommand) -> Self {
        Self { vote_command }
    }

    pub fn account_votes(
        self,
        account: impl Into<String>,
        voteplan: impl Into<String>,
        host: impl Into<String>,
    ) -> Vec<u8> {
        let content = self
            .vote_command
            .account_votes(account, voteplan, host)
            .build()
            .assert()
            .success()
            .get_output()
            .as_lossy_string();
        serde_yaml::from_str(&content).expect("JCLI returned malformed proposals")
    }
}