Skip to content

Commit b862a95

Browse files
authored
Merge pull request #3 from akuzia/error-output
getErrorOutput wont fallback to stdout
2 parents 479bc06 + 6c62b1a commit b862a95

2 files changed

Lines changed: 32 additions & 1 deletion

File tree

src/Dplr/TaskReport.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public function getOutput(): ?string
9292
public function getErrorOutput(): ?string
9393
{
9494
if (isset($this->data['Stderr'])) {
95-
return $this->data['Stderr'] ?: $this->data['Stdout'];
95+
return $this->data['Stderr'];
9696
}
9797

9898
if (isset($this->data['ErrorMsg'])) {

tests/Dplr/Tests/TaskReportTest.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,35 @@ public function testSuccessful()
6666
$this->assertNull($taskReport->getErrorOutput());
6767
$this->assertEquals('output', $taskReport->getOutput());
6868
}
69+
70+
public function testNotSuccessfulWithoutStdout()
71+
{
72+
$taskReport = new TaskReport(
73+
[
74+
'Type' => TaskReport::TYPE_REPLY,
75+
'Success' => false,
76+
'Stderr' => 'error',
77+
],
78+
new Task(['Action' => 'ssh', 'Cmd' => 'ls -al'])
79+
);
80+
81+
$this->assertFalse($taskReport->isSuccessful());
82+
$this->assertEquals('error', $taskReport->getErrorOutput());
83+
$this->assertNull($taskReport->getOutput());
84+
}
85+
86+
public function testNotSuccessfulWithoutStderr()
87+
{
88+
$taskReport = new TaskReport(
89+
[
90+
'Type' => TaskReport::TYPE_REPLY,
91+
'Success' => false,
92+
],
93+
new Task(['Action' => 'ssh', 'Cmd' => 'ls -al'])
94+
);
95+
96+
$this->assertFalse($taskReport->isSuccessful());
97+
$this->assertNull($taskReport->getErrorOutput());
98+
$this->assertNull($taskReport->getOutput());
99+
}
69100
}

0 commit comments

Comments
 (0)