Use bytes for command stdin

This commit is contained in:
Adrian Heine 2021-12-26 00:07:11 +01:00
parent 52e00de3bb
commit fb23353453
3 changed files with 14 additions and 14 deletions

View file

@ -21,13 +21,13 @@ impl<'r, U, R> Cron<'r, String, U, R> {
}
#[async_trait(?Send)]
impl<C: AsRef<str>, U: AsRef<str>, R: CommandRunner> Symbol for Cron<'_, C, U, R> {
impl<C: AsRef<[u8]>, U: AsRef<str>, R: CommandRunner> Symbol for Cron<'_, C, U, R> {
async fn target_reached(&self) -> Result<bool, Box<dyn Error>> {
let tab = self
.command_runner
.get_output("crontab", args!["-l", "-u", self.user.as_ref()])
.await?;
Ok(tab == self.content.as_ref().as_bytes())
Ok(tab == self.content.as_ref())
}
async fn execute(&self) -> Result<(), Box<dyn Error>> {

View file

@ -110,9 +110,9 @@ mod test {
}
#[async_trait(?Send)]
impl CommandRunner for DummyCommandRunner {
async fn run(&self, program: &str, args: &[&OsStr], stdin: &str) -> IoResult<Output> {
async fn run(&self, program: &str, args: &[&OsStr], stdin: &[u8]) -> IoResult<Output> {
assert_eq!(program, "git");
assert_eq!(stdin, "");
assert_eq!(stdin, b"");
sleep(Duration::from_millis(50)).await;
self
.args