[Nostromo] Refactor FS Tasks flagging system

This commit is contained in:
Andrés Montañez
2017-02-11 00:30:49 -03:00
parent 2c087ab477
commit f6886f3d28
9 changed files with 131 additions and 65 deletions
+3 -6
View File
@@ -29,14 +29,13 @@ class ChangeModeTest extends TestCase
$task->setRuntime($runtime);
$this->assertContains('a.txt', $task->getDescription());
$this->assertContains('-R', $task->getDescription());
$this->assertContains('o+w', $task->getDescription());
$task->execute();
$ranCommands = $runtime->getRanCommands();
$testCase = array(
0 => 'chmod -R o+w a.txt',
0 => 'chmod -R o+w "a.txt"',
);
// Check total of Executed Commands
@@ -59,14 +58,13 @@ class ChangeModeTest extends TestCase
$task->setRuntime($runtime);
$this->assertContains('a.txt', $task->getDescription());
$this->assertNotContains('-R', $task->getDescription());
$this->assertContains('o+w', $task->getDescription());
$task->execute();
$ranCommands = $runtime->getRanCommands();
$testCase = array(
0 => 'chmod o+w a.txt',
0 => 'chmod o+w "a.txt"',
);
// Check total of Executed Commands
@@ -89,14 +87,13 @@ class ChangeModeTest extends TestCase
$task->setRuntime($runtime);
$this->assertContains('test.txt', $task->getDescription());
$this->assertContains('-R', $task->getDescription());
$this->assertContains('o+w', $task->getDescription());
$task->execute();
$ranCommands = $runtime->getRanCommands();
$testCase = array(
0 => 'chmod -R o+w test.txt',
0 => 'chmod -R o+w "test.txt"',
);
// Check total of Executed Commands
+91 -4
View File
@@ -50,6 +50,35 @@ class FileSystemTaskTest extends TestCase
}
}
public function testCopyTaskWithFlags()
{
$runtime = new RuntimeMockup();
$runtime->setConfiguration(['environments' => ['test' => []]]);
$runtime->setEnvironment('test');
$task = new CopyTask();
$task->setOptions(['from' => 'a.txt', 'to' => 'b.txt', 'flags' => '-rp']);
$task->setRuntime($runtime);
$this->assertContains('a.txt', $task->getDescription());
$this->assertContains('b.txt', $task->getDescription());
$task->execute();
$ranCommands = $runtime->getRanCommands();
$testCase = array(
0 => 'cp -rp "a.txt" "b.txt"',
);
// Check total of Executed Commands
$this->assertEquals(count($testCase), count($ranCommands));
// Check Generated Commands
foreach ($testCase as $index => $command) {
$this->assertEquals($command, $ranCommands[$index]);
}
}
public function testCopyReplaceTask()
{
$runtime = new RuntimeMockup();
@@ -147,7 +176,36 @@ class FileSystemTaskTest extends TestCase
$ranCommands = $runtime->getRanCommands();
$testCase = array(
0 => 'mv "a.txt" "b.txt"',
0 => 'mv "a.txt" "b.txt"',
);
// Check total of Executed Commands
$this->assertEquals(count($testCase), count($ranCommands));
// Check Generated Commands
foreach ($testCase as $index => $command) {
$this->assertEquals($command, $ranCommands[$index]);
}
}
public function testMoveWithFlagsTask()
{
$runtime = new RuntimeMockup();
$runtime->setConfiguration(['environments' => ['test' => []]]);
$runtime->setEnvironment('test');
$task = new MoveTask();
$task->setOptions(['from' => 'a.txt', 'to' => 'b.txt', 'flags' => '-n']);
$task->setRuntime($runtime);
$this->assertContains('a.txt', $task->getDescription());
$this->assertContains('b.txt', $task->getDescription());
$task->execute();
$ranCommands = $runtime->getRanCommands();
$testCase = array(
0 => 'mv -n "a.txt" "b.txt"',
);
// Check total of Executed Commands
@@ -176,7 +234,7 @@ class FileSystemTaskTest extends TestCase
$ranCommands = $runtime->getRanCommands();
$testCase = array(
0 => 'mv "test.txt" "b.txt"',
0 => 'mv "test.txt" "b.txt"',
);
// Check total of Executed Commands
@@ -224,7 +282,7 @@ class FileSystemTaskTest extends TestCase
$ranCommands = $runtime->getRanCommands();
$testCase = array(
0 => 'rm "a.txt"',
0 => 'rm "a.txt"',
);
// Check total of Executed Commands
@@ -280,7 +338,7 @@ class FileSystemTaskTest extends TestCase
$ranCommands = $runtime->getRanCommands();
$testCase = array(
0 => 'rm "test.txt"',
0 => 'rm "test.txt"',
);
// Check total of Executed Commands
@@ -341,6 +399,35 @@ class FileSystemTaskTest extends TestCase
}
}
public function testLinkTaskWithFlags()
{
$runtime = new RuntimeMockup();
$runtime->setConfiguration(['environments' => ['test' => []]]);
$runtime->setEnvironment('test');
$task = new LinkTask();
$task->setOptions(['from' => 'a.txt', 'to' => 'b.txt', 'flags' => '-P']);
$task->setRuntime($runtime);
$this->assertContains('a.txt', $task->getDescription());
$this->assertContains('b.txt', $task->getDescription());
$task->execute();
$ranCommands = $runtime->getRanCommands();
$testCase = array(
0 => 'ln -P "a.txt" "b.txt"',
);
// Check total of Executed Commands
$this->assertEquals(count($testCase), count($ranCommands));
// Check Generated Commands
foreach ($testCase as $index => $command) {
$this->assertEquals($command, $ranCommands[$index]);
}
}
public function testLinkReplaceTask()
{
$runtime = new RuntimeMockup();