3
3
require "test_helper"
4
4
5
5
class TestLitestream < Minitest ::Test
6
+ def teardown
7
+ Litestream . systemctl_command = nil
8
+ end
9
+
6
10
def test_that_it_has_a_version_number
7
11
refute_nil ::Litestream ::VERSION
8
12
end
@@ -28,6 +32,29 @@ def test_replicate_process_systemd
28
32
end
29
33
end
30
34
35
+ def test_replicate_process_systemd_custom_command
36
+ stubbed_status = [ "● myapp-litestream.service - Litestream" ,
37
+ " Loaded: loaded (/lib/systemd/system/litestream.service; enabled; vendor preset: enabled)" ,
38
+ " Active: active (running) since Tue 2023-07-25 13:49:43 UTC; 8 months 24 days ago" ,
39
+ " Main PID: 1179656 (litestream)" ,
40
+ " Tasks: 9 (limit: 1115)" ,
41
+ " Memory: 22.9M" ,
42
+ " CPU: 10h 49.843s" ,
43
+ " CGroup: /system.slice/litestream.service" ,
44
+ " └─1179656 /usr/bin/litestream replicate" ,
45
+ "" ,
46
+ "Warning: some journal files were not opened due to insufficient permissions." ] . join ( "\n " )
47
+ Litestream . systemctl_command = "systemctl --user status myapp-litestream.service"
48
+
49
+ Litestream . stub :` , stubbed_status do
50
+ info = Litestream . replicate_process
51
+
52
+ assert_equal info [ :status ] , "running"
53
+ assert_equal info [ :pid ] , "1179656"
54
+ assert_equal info [ :started ] . class , DateTime
55
+ end
56
+ end
57
+
31
58
def test_replicate_process_ps
32
59
stubbed_ps_list = [
33
60
"40358 ttys008 0:01.11 ruby --yjit bin/rails litestream:replicate" ,
0 commit comments