mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-01 05:56:16 +00:00
refactoring (#116)
- refactoring architecture - fix incomplete ssh logs - code editor for scripts in the app - remove Jobs and SSHCommands
This commit is contained in:
@ -22,7 +22,7 @@ public function test_see_cronjobs_list()
|
||||
]);
|
||||
|
||||
$this->get(route('servers.cronjobs', $this->server))
|
||||
->assertSeeText($cronjob->frequency_label);
|
||||
->assertSeeText($cronjob->frequencyLabel());
|
||||
}
|
||||
|
||||
public function test_delete_cronjob()
|
||||
@ -34,16 +34,20 @@ public function test_delete_cronjob()
|
||||
/** @var CronJob $cronjob */
|
||||
$cronjob = CronJob::factory()->create([
|
||||
'server_id' => $this->server->id,
|
||||
'user' => 'vito',
|
||||
]);
|
||||
|
||||
$this->delete(route('servers.cronjobs.destroy', [
|
||||
'server' => $this->server,
|
||||
'cronJob' => $cronjob,
|
||||
]))->assertSessionHasNoErrors();
|
||||
]))->assertSessionDoesntHaveErrors();
|
||||
|
||||
$this->assertDatabaseMissing('cron_jobs', [
|
||||
'id' => $cronjob->id,
|
||||
]);
|
||||
|
||||
SSH::assertExecutedContains("echo '' | sudo -u vito crontab -");
|
||||
SSH::assertExecutedContains('sudo -u vito crontab -l');
|
||||
}
|
||||
|
||||
public function test_create_cronjob()
|
||||
@ -56,7 +60,7 @@ public function test_create_cronjob()
|
||||
'command' => 'ls -la',
|
||||
'user' => 'vito',
|
||||
'frequency' => '* * * * *',
|
||||
])->assertSessionHasNoErrors();
|
||||
])->assertSessionDoesntHaveErrors();
|
||||
|
||||
$this->assertDatabaseHas('cron_jobs', [
|
||||
'server_id' => $this->server->id,
|
||||
@ -65,5 +69,33 @@ public function test_create_cronjob()
|
||||
'frequency' => '* * * * *',
|
||||
'status' => CronjobStatus::READY,
|
||||
]);
|
||||
|
||||
SSH::assertExecutedContains("echo '* * * * * ls -la' | sudo -u vito crontab -");
|
||||
SSH::assertExecutedContains('sudo -u vito crontab -l');
|
||||
}
|
||||
|
||||
public function test_create_custom_cronjob()
|
||||
{
|
||||
SSH::fake();
|
||||
|
||||
$this->actingAs($this->user);
|
||||
|
||||
$this->post(route('servers.cronjobs.store', $this->server), [
|
||||
'command' => 'ls -la',
|
||||
'user' => 'vito',
|
||||
'frequency' => 'custom',
|
||||
'custom' => '* * * 1 1',
|
||||
])->assertSessionDoesntHaveErrors();
|
||||
|
||||
$this->assertDatabaseHas('cron_jobs', [
|
||||
'server_id' => $this->server->id,
|
||||
'command' => 'ls -la',
|
||||
'user' => 'vito',
|
||||
'frequency' => '* * * 1 1',
|
||||
'status' => CronjobStatus::READY,
|
||||
]);
|
||||
|
||||
SSH::assertExecutedContains("echo '* * * 1 1 ls -la' | sudo -u vito crontab -");
|
||||
SSH::assertExecutedContains('sudo -u vito crontab -l');
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user