-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathcli_spec.cr
147 lines (133 loc) · 4.1 KB
/
cli_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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
require "../src/cli"
require "./prefix_helper"
require "file_utils"
def install_dppm(prefix : String)
DPPM::CLI.install_dppm(
no_confirm: true,
config: DPPM_CONFIG_FILE,
prefix: prefix,
group: DPPM::Prefix.default_group,
source_name: DPPM::Prefix.default_source_name,
source_path: nil
)
end
def build_package(prefix_path : String, package : String = TEST_APP_PACKAGE_NAME)
pkg = DPPM::CLI::Pkg.build(
no_confirm: true,
config: DPPM_CONFIG_FILE,
source_name: DPPM::Prefix.default_source_name,
source_path: SAMPLES_DIR,
prefix: prefix_path,
package: package,
custom_vars: Array(String).new)
pkg.name.starts_with?(TEST_APP_PACKAGE_NAME).should be_true
pkg.exists?.should eq pkg
end
def add_application(prefix_path : String, application : String = TEST_APP_PACKAGE_NAME, name : String = TEST_APP_PACKAGE_NAME, version : String? = nil)
app = DPPM::CLI::App.add(
no_confirm: true,
config: DPPM_CONFIG_FILE,
group: DPPM::Prefix.default_group,
source_name: DPPM::Prefix.default_source_name,
source_path: SAMPLES_DIR,
prefix: prefix_path,
application: application,
name: name,
version: version,
contained: false,
noservice: true,
socket: false)
app.name.starts_with?(TEST_APP_PACKAGE_NAME).should be_true
app.exists?.should eq app
end
def upgrade_application(prefix_path : String, version : String, application : String = TEST_APP_PACKAGE_NAME)
app = DPPM::CLI::App.upgrade(
no_confirm: true,
config: DPPM_CONFIG_FILE,
group: DPPM::Prefix.default_group,
source_name: DPPM::Prefix.default_source_name,
source_path: SAMPLES_DIR,
prefix: prefix_path,
application: application,
contained: false,
version: version,
)
app.pkg.version.should eq version
end
def delete_application(prefix_path : String, application : String = TEST_APP_PACKAGE_NAME)
app = DPPM::CLI::App.delete(
no_confirm: true,
prefix: prefix_path,
group: DPPM::Prefix.default_group,
application: application,
keep_user_group: false,
preserve_database: false).not_nil!
app.name.should eq application
app.exists?.should be_nil
end
describe DPPM::CLI do
it "installs DPPM" do
spec_with_tempdir do |prefix|
install_dppm prefix
dppm_prefix = DPPM::Prefix.new prefix
dppm_prefix.dppm.config_file?.should_not be_nil
dppm_prefix.dppm_config
end
end
it "uninstalls DPPM" do
spec_with_tempdir do |prefix|
install_dppm prefix
DPPM::CLI.uninstall_dppm(
no_confirm: true,
config: DPPM_CONFIG_FILE,
prefix: prefix,
group: DPPM::Prefix.default_group,
source_name: DPPM::Prefix.default_source_name,
source_path: nil
)
end
end
describe DPPM::CLI::Pkg do
it "cleans unused packages" do
spec_with_prefix do |prefix|
build_package prefix.path.to_s
Dir.rmdir (prefix.app / "dppm").to_s
packages = prefix.clean_unused_packages(false) { }
packages.not_nil!.should eq Set{"libfake_0.0.1", "testapp_0.2.0"}
Dir.children(prefix.pkg.to_s).should be_empty
end
end
it "builds a packages" do
spec_with_prefix do |prefix|
build_package prefix.path.to_s
end
end
end
describe DPPM::CLI::App do
it "adds an application with a version and no package built" do
spec_with_prefix do |prefix|
add_application prefix_path: prefix.path.to_s, version: "0.3.0"
delete_application prefix.path.to_s
end
end
it "adds an application" do
spec_with_prefix do |prefix|
add_application prefix_path: prefix.path.to_s
delete_application prefix.path.to_s
end
end
it "upgrades an application" do
spec_with_prefix do |prefix|
add_application prefix_path: prefix.path.to_s
upgrade_application prefix_path: prefix.path.to_s, version: "0.3.0"
delete_application prefix.path.to_s
end
end
it "deletes an application" do
spec_with_prefix do |prefix|
add_application prefix_path: prefix.path.to_s
delete_application prefix.path.to_s
end
end
end
end