Debian Codegraph @

features/install/forge.feature

raw
1 Feature: cli/install/forge
2 Puppet librarian needs to install modules from the Puppet Forge
3
4 Scenario: Installing a module and its dependencies
5 Given a file named "Puppetfile" with:
6 """
7 forge "https://forgeapi.puppet.com"
8
9 mod 'puppetlabs/ntp'
10 """
11 When I successfully run `librarian-puppet install`
12 And the file "modules/ntp/metadata.json" should match /"name": "puppetlabs-ntp"/
13 And the file "modules/stdlib/metadata.json" should match /"name": "puppetlabs-stdlib"/
14
15 Scenario: Running install with no Puppetfile and metadata.json
16 Given there is no Puppetfile
17 And a file named "metadata.json" with:
18 """
19 {
20 "name": "random name",
21 "dependencies": [
22 {
23 "name": "puppetlabs/stdlib",
24 "version_requirement": "4.1.0"
25 }
26 ]
27 }
28 """
29 When I successfully run `librarian-puppet install`
30 And the file "modules/stdlib/metadata.json" should match /"name": "puppetlabs-stdlib"/
31
32 Scenario: Installing a module without forge
33 Given a file named "Puppetfile" with:
34 """
35 mod 'puppetlabs/stdlib', '4.1.0'
36 """
37 When I run `librarian-puppet install`
38 Then the exit status should be 1
39 And the output should contain "forge entry is not defined in Puppetfile"
40
41 Scenario: Installing an exact version of a module
42 Given a file named "Puppetfile" with:
43 """
44 forge "https://forgeapi.puppet.com"
45
46 mod 'puppetlabs/apt', '0.0.4'
47 """
48 When I successfully run `librarian-puppet install`
49 And the file "modules/apt/Modulefile" should match /name *'puppetlabs-apt'/
50 And the file "modules/apt/Modulefile" should match /version *'0\.0\.4'/
51 And the file "modules/stdlib/metadata.json" should match /"name": "puppetlabs-stdlib"/
52
53 # Puppet Module tool does not support spaces
54 # https://github.com/rodjek/librarian-puppet/issues/201
55 # https://tickets.puppetlabs.com/browse/PUP-2278
56 @spaces
57 Scenario: Installing a module in a path with spaces
58 Given a file named "Puppetfile" with:
59 """
60 forge "https://forgeapi.puppet.com"
61 mod 'puppetlabs/stdlib', '4.1.0'
62 """
63 When PENDING I run `librarian-puppet install`
64 Then the exit status should be 0
65 And the file "modules/stdlib/metadata.json" should match /"name": "puppetlabs-stdlib"/
66
67 Scenario: Installing a module with invalid versions in the forge
68 Given a file named "Puppetfile" with:
69 """
70 forge "https://forgeapi.puppet.com"
71
72 mod 'puppetlabs/apache', '7.0.0' # compatible with stdlib 8
73 mod 'puppetlabs/postgresql', '7.4.0' # incompatible with stdlib 8
74
75 """
76 # Default timeout is 15 seconds but this is too short in most cases
77 When I successfully run `librarian-puppet install --verbose` for up to 30 seconds
78 And the file "modules/apache/metadata.json" should match /"name": "puppetlabs-apache"/
79 And the file "modules/apache/metadata.json" should match /"version": "7\.0\.0"/
80 And the file "modules/postgresql/metadata.json" should match /"name": "puppetlabs-postgresql"/
81 And the file "modules/postgresql/metadata.json" should match /"version": "7\.4\.0"/
82 And the file "modules/stdlib/metadata.json" should match /"name": "puppetlabs-stdlib"/
83 And the file "modules/stdlib/metadata.json" should match /"version": "7\.1\.0"/
84
85 Scenario: Installing a module with several constraints
86 Given a file named "Puppetfile" with:
87 """
88 forge "https://forgeapi.puppet.com"
89
90 mod 'puppetlabs/apt', '>=1.0.0', '<1.0.1'
91 """
92 When I successfully run `librarian-puppet install`
93 And the file "modules/apt/Modulefile" should match /name *'puppetlabs-apt'/
94 And the file "modules/apt/Modulefile" should match /version *'1\.0\.0'/
95 And the file "modules/stdlib/metadata.json" should match /"name": "puppetlabs-stdlib"/
96
97 Scenario: Changing the path
98 Given a directory named "puppet"
99 And a file named "Puppetfile" with:
100 """
101 forge "https://forgeapi.puppet.com"
102
103 mod 'puppetlabs/ntp', '3.0.3'
104 """
105 When I run `librarian-puppet install --path puppet/modules`
106 And I run `librarian-puppet config`
107 Then the exit status should be 0
108 And the output from "librarian-puppet config" should contain "path: puppet/modules"
109 And the file "puppet/modules/ntp/Modulefile" should match /name *'puppetlabs-ntp'/
110 And the file "puppet/modules/stdlib/metadata.json" should match /"name": "puppetlabs-stdlib"/
111
112 Scenario: Handle range version numbers
113 Given a file named "Puppetfile" with:
114 """
115 forge "https://forgeapi.puppet.com"
116
117 mod 'puppetlabs/postgresql', '7.4.1'
118 mod 'puppetlabs/apt', '< 8.4.0'
119 """
120 When I successfully run `librarian-puppet install`
121 And the file "modules/postgresql/metadata.json" should match /"name": "puppetlabs-postgresql"/
122 And the file "modules/postgresql/metadata.json" should match /"version": "7\.4\.1"/
123 And the file "modules/apt/metadata.json" should match /"name": "puppetlabs-apt"/
124 And the file "modules/apt/metadata.json" should match /"version": "8\.3\.0"/
125
126 Given a file named "Puppetfile" with:
127 """
128 forge "https://forgeapi.puppet.com"
129
130 mod 'puppetlabs/postgresql', :git => 'https://github.com/puppetlabs/puppet-postgresql', :ref => 'v7.5.0'
131 """
132 When I successfully run `librarian-puppet install`
133 And the file "modules/postgresql/metadata.json" should match /"name": "puppetlabs-postgresql"/
134 And the file "modules/postgresql/metadata.json" should match /"version": "7\.5\.0"/
135 And the file "modules/apt/metadata.json" should match /"name": "puppetlabs-apt"/
136 And the file "modules/apt/metadata.json" should not match /"version": "8\.3\.0"/
137
138 Scenario: Installing a module that does not exist
139 Given a file named "Puppetfile" with:
140 """
141 forge "https://forgeapi.puppet.com"
142
143 mod 'puppetlabs/xxxxx'
144 """
145 When I run `librarian-puppet install`
146 Then the exit status should be 1
147 And the output should match:
148 """
149 Unable to find module 'puppetlabs-xxxxx' on https://forgeapi.puppet.com
150 """
151
152 Scenario: Install a module with conflicts
153 Given a file named "Puppetfile" with:
154 """
155 forge "https://forgeapi.puppet.com"
156
157 mod 'puppetlabs/apache', '0.6.0'
158 mod 'puppetlabs/stdlib', '<2.2.1'
159 """
160 When I run `librarian-puppet install`
161 Then the exit status should be 1
162 And the output should contain "Could not resolve the dependencies"
163
164 Scenario: Install a module from the Forge with dependencies without version
165 Given a file named "Puppetfile" with:
166 """
167 forge "https://forgeapi.puppet.com"
168
169 mod 'sbadia/gitlab', '0.1.0'
170 """
171 When I successfully run `librarian-puppet install`
172 And the file "modules/gitlab/Modulefile" should match /version *'0\.1\.0'/
173
174 Scenario: Source dependencies from metadata.json
175 Given a file named "Puppetfile" with:
176 """
177 forge "https://forgeapi.puppet.com"
178
179 metadata
180 """
181 And a file named "metadata.json" with:
182 """
183 {
184 "name": "random name",
185 "dependencies": [
186 {
187 "name": "puppetlabs/postgresql",
188 "version_requirement": "4.0.0"
189 }
190 ]
191 }
192 """
193 When I successfully run `librarian-puppet install`
194 And the file "modules/postgresql/metadata.json" should match /"name": "puppetlabs-postgresql"/
195
196 Scenario: Installing a module with duplicated dependencies
197 Given a file named "Puppetfile" with:
198 """
199 forge "https://forgeapi.puppet.com"
200
201 mod 'pdxcat/collectd', '2.1.0'
202 """
203 When I successfully run `librarian-puppet install`
204 And the file "modules/collectd/Modulefile" should match /name *'pdxcat-collectd'/
205 And the file "modules/stdlib/metadata.json" should match /"name": "puppetlabs-stdlib"/
206
207 Scenario: Installing two modules with same name, alphabetical order wins
208 Given a file named "Puppetfile" with:
209 """
210 forge "https://forgeapi.puppet.com"
211
212 mod 'theforeman-dhcp', '4.0.0'
213 mod 'puppet-dhcp', '2.0.0'
214 """
215 When I successfully run `librarian-puppet install --verbose`
216 And the file "modules/dhcp/metadata.json" should match /"name": "theforeman-dhcp"/
217 And the output should contain "Dependency on module 'dhcp' is fullfilled by multiple modules and only one will be used"
218
219 @other-forge
220 Scenario: Installing from another forge with local reference should not try to download anything from the official forge
221 Given a file named "Puppetfile" with:
222 """
223 forge "http://127.0.0.1:8080"
224
225 mod 'tester/tester', :path => './tester-tester'
226 """
227 And a file named "tester-tester/metadata.json" with:
228 """
229 {
230 "name": "tester-tester",
231 "version": "0.1.0",
232 "author": "Basilio Vera",
233 "summary": "Just our own test",
234 "license": "MIT",
235 "dependencies": [
236 { "name": "puppetlabs/inifile" }
237 ]
238 }
239 """
240
241 When I run `librarian-puppet install --verbose`
242 And the output should not contain "puppetlabs.com"
243 And the output should not contain "puppet.com"
244 And the output should contain "Resolving puppetlabs-inifile (>= 0) <http://127.0.0.1:8080>"