@@ -81,156 +81,6 @@ def expect_pkgadd_with_env_and_name(source, &block)
81
81
end
82
82
83
83
context "#install" do
84
- it "should fail if the resource doesn't have a source" do
85
- expect ( Puppet ::FileSystem ) . to receive ( :exist? ) . with ( '/etc/pkg.conf' ) . and_return ( false )
86
-
87
- expect {
88
- provider . install
89
- } . to raise_error ( Puppet ::Error , /must specify a package source/ )
90
- end
91
-
92
- it "should fail if /etc/pkg.conf exists, but is not readable" do
93
- expect ( Puppet ::FileSystem ) . to receive ( :exist? ) . with ( '/etc/pkg.conf' ) . and_return ( true )
94
- expect ( File ) . to receive ( :open ) . with ( '/etc/pkg.conf' , 'rb' ) . and_raise ( Errno ::EACCES )
95
-
96
- expect {
97
- provider . install
98
- } . to raise_error ( Errno ::EACCES , /Permission denied/ )
99
- end
100
-
101
- it "should fail if /etc/pkg.conf exists, but there is no installpath" do
102
- expect_read_from_pkgconf ( [ ] )
103
- expect {
104
- provider . install
105
- } . to raise_error ( Puppet ::Error , /No valid installpath found in \/ etc\/ pkg\. conf and no source was set/ )
106
- end
107
-
108
- it "should install correctly when given a directory-unlike source" do
109
- source = '/whatever.tgz'
110
- provider . resource [ :source ] = source
111
- expect_pkgadd_with_source ( source )
112
-
113
- provider . install
114
- end
115
-
116
- it "should install correctly when given a directory-like source" do
117
- source = '/whatever/'
118
- provider . resource [ :source ] = source
119
- expect_pkgadd_with_env_and_name ( source ) do
120
- provider . install
121
- end
122
- end
123
-
124
- it "should install correctly when given a CDROM installpath" do
125
- dir = '/mnt/cdrom/5.2/packages/amd64/'
126
- expect_read_from_pkgconf ( [ "installpath = #{ dir } " ] )
127
- expect_pkgadd_with_env_and_name ( dir ) do
128
- provider . install
129
- end
130
- end
131
-
132
- it "should install correctly when given a ftp mirror" do
133
- url = 'ftp://your.ftp.mirror/pub/OpenBSD/5.2/packages/amd64/'
134
- expect_read_from_pkgconf ( [ "installpath = #{ url } " ] )
135
- expect_pkgadd_with_env_and_name ( url ) do
136
- provider . install
137
- end
138
- end
139
-
140
- it "should set the resource's source parameter" do
141
- url = 'ftp://your.ftp.mirror/pub/OpenBSD/5.2/packages/amd64/'
142
- expect_read_from_pkgconf ( [ "installpath = #{ url } " ] )
143
- expect_pkgadd_with_env_and_name ( url ) do
144
- provider . install
145
- end
146
-
147
- expect ( provider . resource [ :source ] ) . to eq ( url )
148
- end
149
-
150
- it "should strip leading whitespace in installpath" do
151
- dir = '/one/'
152
- lines = [ "# Notice the extra spaces after the ='s\n " ,
153
- "installpath = #{ dir } \n " ,
154
- "# And notice how each line ends with a newline\n " ]
155
-
156
- expect_read_from_pkgconf ( lines )
157
- expect_pkgadd_with_env_and_name ( dir ) do
158
- provider . install
159
- end
160
- end
161
-
162
- it "should not require spaces around the equals" do
163
- dir = '/one/'
164
- lines = [ "installpath=#{ dir } " ]
165
-
166
- expect_read_from_pkgconf ( lines )
167
- expect_pkgadd_with_env_and_name ( dir ) do
168
- provider . install
169
- end
170
- end
171
-
172
- it "should be case-insensitive" do
173
- dir = '/one/'
174
- lines = [ "INSTALLPATH = #{ dir } " ]
175
-
176
- expect_read_from_pkgconf ( lines )
177
- expect_pkgadd_with_env_and_name ( dir ) do
178
- provider . install
179
- end
180
- end
181
-
182
- it "should ignore unknown keywords" do
183
- dir = '/one/'
184
- lines = [ "foo = bar\n " ,
185
- "installpath = #{ dir } \n " ]
186
-
187
- expect_read_from_pkgconf ( lines )
188
- expect_pkgadd_with_env_and_name ( dir ) do
189
- provider . install
190
- end
191
- end
192
-
193
- it "should preserve trailing spaces" do
194
- dir = '/one/ '
195
- lines = [ "installpath = #{ dir } " ]
196
-
197
- expect_read_from_pkgconf ( lines )
198
- expect_pkgadd_with_source ( dir )
199
-
200
- provider . install
201
- end
202
-
203
- it "should append installpath" do
204
- urls = [ "ftp://your.ftp.mirror/pub/OpenBSD/5.2/packages/amd64/" ,
205
- "http://another.ftp.mirror/pub/OpenBSD/5.2/packages/amd64/" ]
206
- lines = [ "installpath = #{ urls [ 0 ] } \n " ,
207
- "installpath += #{ urls [ 1 ] } \n " ]
208
-
209
- expect_read_from_pkgconf ( lines )
210
- expect_pkgadd_with_env_and_name ( urls . join ( ":" ) ) do
211
- provider . install
212
- end
213
- end
214
-
215
- it "should handle append on first installpath" do
216
- url = "ftp://your.ftp.mirror/pub/OpenBSD/5.2/packages/amd64/"
217
- lines = [ "installpath += #{ url } \n " ]
218
-
219
- expect_read_from_pkgconf ( lines )
220
- expect_pkgadd_with_env_and_name ( url ) do
221
- provider . install
222
- end
223
- end
224
-
225
- %w{ installpath installpath= installpath+= } . each do |line |
226
- it "should reject '#{ line } '" do
227
- expect_read_from_pkgconf ( [ line ] )
228
- expect {
229
- provider . install
230
- } . to raise_error ( Puppet ::Error , /No valid installpath found in \/ etc\/ pkg\. conf and no source was set/ )
231
- end
232
- end
233
-
234
84
it 'should use install_options as Array' do
235
85
provider . resource [ :source ] = '/tma1/'
236
86
provider . resource [ :install_options ] = [ '-r' , '-z' ]
0 commit comments