-
Notifications
You must be signed in to change notification settings - Fork 12
/
service_spec.cr
74 lines (59 loc) · 1.7 KB
/
service_spec.cr
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
require "./spec_helper"
require "../src/service"
require "../src/prefix"
require "file_utils"
module Service
def self.init=(@@init)
@@supported = true
end
module InitSystem
def file=(@file)
end
end
struct Systemd
def self.version=(@@version)
end
end
end
def assert_service(service, file = __FILE__, line = __LINE__)
Service.init = service
user = group = TEST_APP_PACKAGE_NAME
test_prefix = Prefix.new File.tempname("_dppm_service_test")
test_prefix.create
test_app = test_prefix.new_app(TEST_APP_PACKAGE_NAME)
FileUtils.cp_r SAMPLES_DIR + '/' + TEST_APP_PACKAGE_NAME, test_app.path
service_config = test_app.service.config.class.new
test_app.service.file = test_app.service_file
it "creates a service", file, line do
test_app.service_create user, group
end
it "parses the service", file, line do
test_app.service.config
end
it "gets user value", file, line do
test_app.service.config.user.should eq user
end
it "checks service file building", file, line do
File.read(test_app.service_file).should eq test_app.service.config_build
end
it "verifies PATH environment variable", file, line do
test_app.service.config.env_vars["PATH"].should eq test_app.path_env_var
end
FileUtils.rm_r test_prefix.path
Service.init = nil
end
describe Service do
describe Service::OpenRC do
assert_service Service::OpenRC
end
describe Service::Systemd do
describe "version < 236 with file logging workaround" do
Service::Systemd.version = 230
assert_service Service::Systemd
end
describe "recent version supporting file logging" do
Service::Systemd.version = 240
assert_service Service::Systemd
end
end
end