Add grep's context option to show lines before and after a match
This commit is contained in:
@@ -114,6 +114,21 @@ class CliAccessoryTest < CliTestCase
|
||||
.with("ssh -t root@1.1.1.3 'docker logs app-mysql --timestamps --tail 10 2>&1'")
|
||||
|
||||
assert_match "docker logs app-mysql --tail 100 --timestamps 2>&1", run_command("logs", "mysql")
|
||||
|
||||
end
|
||||
|
||||
test "logs with grep" do
|
||||
SSHKit::Backend::Abstract.any_instance.stubs(:exec)
|
||||
.with("ssh -t root@1.1.1.3 'docker logs app-mysql --timestamps 2>&1 | grep \'hey\''")
|
||||
|
||||
assert_match "docker logs app-mysql --timestamps 2>&1 | grep 'hey'", run_command("logs", "mysql", "--grep", "hey")
|
||||
end
|
||||
|
||||
test "logs with grep and context" do
|
||||
SSHKit::Backend::Abstract.any_instance.stubs(:exec)
|
||||
.with("ssh -t root@1.1.1.3 'docker logs app-mysql --timestamps 2>&1 | grep \'hey\' -C 2'")
|
||||
|
||||
assert_match "docker logs app-mysql --timestamps 2>&1 | grep 'hey' -C 2", run_command("logs", "mysql", "--grep", "hey", "--context", "2")
|
||||
end
|
||||
|
||||
test "logs with follow" do
|
||||
@@ -123,6 +138,20 @@ class CliAccessoryTest < CliTestCase
|
||||
assert_match "docker logs app-mysql --timestamps --tail 10 --follow 2>&1", run_command("logs", "mysql", "--follow")
|
||||
end
|
||||
|
||||
test "logs with follow and grep" do
|
||||
SSHKit::Backend::Abstract.any_instance.stubs(:exec)
|
||||
.with("ssh -t root@1.1.1.3 -p 22 'docker logs app-mysql --timestamps --tail 10 --follow 2>&1 | grep \"hey\"'")
|
||||
|
||||
assert_match "docker logs app-mysql --timestamps --tail 10 --follow 2>&1 | grep \"hey\"", run_command("logs", "mysql", "--follow", "--grep", "hey")
|
||||
end
|
||||
|
||||
test "logs with follow, grep, and context" do
|
||||
SSHKit::Backend::Abstract.any_instance.stubs(:exec)
|
||||
.with("ssh -t root@1.1.1.3 -p 22 'docker logs app-mysql --timestamps --tail 10 --follow 2>&1 | grep \"hey\" -C 2'")
|
||||
|
||||
assert_match "docker logs app-mysql --timestamps --tail 10 --follow 2>&1 | grep \"hey\" -C 2", run_command("logs", "mysql", "--follow", "--grep", "hey", "--context", "2")
|
||||
end
|
||||
|
||||
test "remove with confirmation" do
|
||||
Kamal::Cli::Accessory.any_instance.expects(:stop).with("mysql")
|
||||
Kamal::Cli::Accessory.any_instance.expects(:remove_container).with("mysql")
|
||||
|
||||
Reference in New Issue
Block a user