albacore 0.2.5 → 0.2.6
Sign up to get free protection for your applications and to get access to all the features.
- data/.autotest +4 -4
- data/.bundle/config +2 -2
- data/.rvmrc +1 -1
- data/Gemfile +12 -12
- data/README.markdown +92 -68
- data/VERSION +1 -1
- data/lib/albacore.rb +9 -9
- data/lib/albacore/albacoretask.rb +50 -50
- data/lib/albacore/aspnetcompiler.rb +58 -58
- data/lib/albacore/assemblyinfo.rb +140 -140
- data/lib/albacore/assemblyinfolanguages/cppcliengine.rb +17 -0
- data/lib/albacore/assemblyinfolanguages/csharpengine.rb +18 -18
- data/lib/albacore/assemblyinfolanguages/vbnetengine.rb +18 -18
- data/lib/albacore/config/aspnetcompilerconfig.rb +29 -29
- data/lib/albacore/config/assemblyinfoconfig.rb +13 -13
- data/lib/albacore/config/config.rb +22 -22
- data/lib/albacore/config/cscconfig.rb +28 -28
- data/lib/albacore/config/docuconfig.rb +23 -23
- data/lib/albacore/config/execconfig.rb +15 -15
- data/lib/albacore/config/fluentmigratorrunnerconfig.rb +15 -15
- data/lib/albacore/config/msbuildconfig.rb +29 -29
- data/lib/albacore/config/mspectestrunnerconfig.rb +15 -15
- data/lib/albacore/config/mstesttestrunnerconfig.rb +15 -15
- data/lib/albacore/config/nantconfig.rb +15 -15
- data/lib/albacore/config/nchurnconfig.rb +15 -15
- data/lib/albacore/config/ncoverconsoleconfig.rb +15 -15
- data/lib/albacore/config/ncoverreportconfig.rb +15 -15
- data/lib/albacore/config/ndependconfig.rb +15 -15
- data/lib/albacore/config/netversion.rb +21 -21
- data/lib/albacore/config/nugetpackconfig.rb +3 -3
- data/lib/albacore/config/nugetpublishconfig.rb +19 -0
- data/lib/albacore/config/nugetpushconfig.rb +19 -0
- data/lib/albacore/config/nunittestrunnerconfig.rb +14 -14
- data/lib/albacore/config/specflowreportconfig.rb +24 -24
- data/lib/albacore/config/sqlcmdconfig.rb +15 -15
- data/lib/albacore/config/unzipconfig.rb +15 -15
- data/lib/albacore/config/vssgetconfig.rb +14 -0
- data/lib/albacore/config/xbuildconfig.rb +15 -15
- data/lib/albacore/config/xunittestrunnerconfig.rb +15 -15
- data/lib/albacore/config/zipdirectoryconfig.rb +15 -15
- data/lib/albacore/csc.rb +66 -62
- data/lib/albacore/docu.rb +41 -41
- data/lib/albacore/exec.rb +18 -18
- data/lib/albacore/fluentmigratorrunner.rb +51 -46
- data/lib/albacore/msbuild.rb +55 -55
- data/lib/albacore/mspectestrunner.rb +50 -50
- data/lib/albacore/mstesttestrunner.rb +43 -43
- data/lib/albacore/nant.rb +38 -38
- data/lib/albacore/nchurn.rb +74 -74
- data/lib/albacore/ncoverconsole.rb +68 -68
- data/lib/albacore/ncoverreport.rb +62 -62
- data/lib/albacore/ncoverreports/assemblyfilter.rb +9 -9
- data/lib/albacore/ncoverreports/branchcoverage.rb +9 -9
- data/lib/albacore/ncoverreports/classfilter.rb +9 -9
- data/lib/albacore/ncoverreports/codecoveragebase.rb +25 -25
- data/lib/albacore/ncoverreports/cyclomaticcomplexity.rb +23 -23
- data/lib/albacore/ncoverreports/documentfilter.rb +9 -9
- data/lib/albacore/ncoverreports/fullcoveragereport.rb +13 -13
- data/lib/albacore/ncoverreports/methodcoverage.rb +9 -9
- data/lib/albacore/ncoverreports/methodfilter.rb +9 -9
- data/lib/albacore/ncoverreports/namespacefilter.rb +9 -9
- data/lib/albacore/ncoverreports/reportfilterbase.rb +26 -26
- data/lib/albacore/ncoverreports/summaryreport.rb +18 -18
- data/lib/albacore/ncoverreports/symbolcoverage.rb +9 -9
- data/lib/albacore/ndepend.rb +33 -33
- data/lib/albacore/nugetpublish.rb +47 -0
- data/lib/albacore/nugetpush.rb +46 -0
- data/lib/albacore/nunittestrunner.rb +41 -41
- data/lib/albacore/nuspec.rb +133 -109
- data/lib/albacore/output.rb +99 -99
- data/lib/albacore/plink.rb +47 -47
- data/lib/albacore/specflowreport.rb +62 -62
- data/lib/albacore/sqlcmd.rb +80 -80
- data/lib/albacore/support/attrmethods.rb +33 -33
- data/lib/albacore/support/createtask.rb +50 -30
- data/lib/albacore/support/failure.rb +15 -15
- data/lib/albacore/support/logging.rb +38 -38
- data/lib/albacore/support/openstruct.rb +13 -13
- data/lib/albacore/support/runcommand.rb +45 -45
- data/lib/albacore/support/supportlinux.rb +23 -23
- data/lib/albacore/support/updateattributes.rb +13 -13
- data/lib/albacore/support/yamlconfig.rb +18 -18
- data/lib/albacore/unzip.rb +28 -28
- data/lib/albacore/vssget.rb +44 -0
- data/lib/albacore/xbuild.rb +54 -54
- data/lib/albacore/xunittestrunner.rb +52 -52
- data/lib/albacore/zipdirectory.rb +105 -105
- data/rakefile.rb +297 -297
- data/spec/albacoremodel_spec.rb +53 -53
- data/spec/assemblyinfo_spec.rb +541 -541
- data/spec/attrmethods_spec.rb +136 -136
- data/spec/config_spec.rb +34 -34
- data/spec/createtask_spec.rb +236 -236
- data/spec/csc_spec.rb +253 -253
- data/spec/docu_spec.rb +109 -109
- data/spec/exec_spec.rb +45 -45
- data/spec/fluentmigratorrunner_spec.rb +254 -185
- data/spec/msbuild_spec.rb +215 -215
- data/spec/mspec_spec.rb +28 -28
- data/spec/mstesttestrunner_spec.rb +142 -142
- data/spec/nant_spec.rb +110 -110
- data/spec/nchurn_spec.rb +75 -75
- data/spec/ncoverconsole_spec.rb +353 -353
- data/spec/ncoverreport_spec.rb +619 -619
- data/spec/ndepend_spec.rb +72 -72
- data/spec/nunittestrunner_spec.rb +122 -122
- data/spec/nuspec_spec.rb +78 -78
- data/spec/patches/docu_patch.rb +12 -12
- data/spec/patches/fail_patch.rb +8 -8
- data/spec/patches/system_patch.rb +20 -20
- data/spec/plink_spec.rb +62 -62
- data/spec/runcommand_spec.rb +94 -94
- data/spec/spec_helper.rb +17 -17
- data/spec/specflowreport_spec.rb +146 -146
- data/spec/sqlcmd_spec.rb +334 -334
- data/spec/support/assemblyinfotester.rb +51 -51
- data/spec/support/ironruby_validator.rb +26 -26
- data/spec/support/msbuildtestdata.rb +32 -32
- data/spec/support/nanttestdata.rb +33 -33
- data/spec/support/ncoverconsoletestdata.rb +19 -19
- data/spec/support/ncoverreporttestdata.rb +26 -26
- data/spec/support/nokogiri_validator.rb +15 -15
- data/spec/support/outputtestdata.rb +12 -12
- data/spec/support/ziptestdata.rb +12 -12
- data/spec/unzip_spec.rb +15 -15
- data/spec/xbuild_spec.rb +15 -15
- data/spec/xunit_spec.rb +168 -168
- data/spec/yamlconfig_spec.rb +49 -49
- data/spec/zip_spec.rb +104 -104
- data/watchrtesting.rb +8 -8
- metadata +15 -119
data/spec/sqlcmd_spec.rb
CHANGED
@@ -1,334 +1,334 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'albacore/sqlcmd'
|
3
|
-
|
4
|
-
describe SQLCmd, "when running a script the easy way" do
|
5
|
-
before :all do
|
6
|
-
@cmd = SQLCmd.new
|
7
|
-
@cmd.log_level = :verbose
|
8
|
-
@cmd.extend(SystemPatch)
|
9
|
-
@cmd.disable_system = true
|
10
|
-
|
11
|
-
@cmd.scripts "somescript.sql"
|
12
|
-
|
13
|
-
@cmd.execute
|
14
|
-
end
|
15
|
-
|
16
|
-
it "should use localhost as server default" do
|
17
|
-
@cmd.system_command.should include("-S \".\"")
|
18
|
-
end
|
19
|
-
|
20
|
-
it "should have no database designation (because it could be embedded in the sql file)" do
|
21
|
-
@cmd.system_command.should_not include("-d")
|
22
|
-
end
|
23
|
-
|
24
|
-
it "should use integrated security instead of username/password" do
|
25
|
-
@cmd.system_command.should include("-E")
|
26
|
-
end
|
27
|
-
|
28
|
-
it "should not include username" do
|
29
|
-
@cmd.system_command.should_not include("-U")
|
30
|
-
end
|
31
|
-
|
32
|
-
it "should not include password" do
|
33
|
-
@cmd.system_command.should_not include("-P")
|
34
|
-
end
|
35
|
-
|
36
|
-
it "should find the location of the sqlcmd exe for the user" do
|
37
|
-
@cmd.system_command.downcase.should include("sqlcmd.exe")
|
38
|
-
end
|
39
|
-
|
40
|
-
it "should specify the script file" do
|
41
|
-
@cmd.system_command.should include("-i \"somescript.sql\"")
|
42
|
-
end
|
43
|
-
|
44
|
-
it "should not contain the -b option" do
|
45
|
-
@cmd.system_command.should_not include("-b")
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
describe SQLCmd, "when turning off trusted_connection" do
|
50
|
-
before :all do
|
51
|
-
@cmd = SQLCmd.new
|
52
|
-
@cmd.log_level = :verbose
|
53
|
-
@cmd.extend(SystemPatch)
|
54
|
-
@cmd.disable_system = true
|
55
|
-
|
56
|
-
@cmd.scripts "somescript.sql"
|
57
|
-
@cmd.trusted_connection = false
|
58
|
-
|
59
|
-
@cmd.execute
|
60
|
-
end
|
61
|
-
|
62
|
-
it "should not specify the -E option" do
|
63
|
-
@cmd.system_command.should_not include("-E")
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
describe SQLCmd, "when using a trusted connection with a username and password" do
|
68
|
-
before :all do
|
69
|
-
@cmd = SQLCmd.new
|
70
|
-
@cmd.log_level = :verbose
|
71
|
-
@cmd.extend(SystemPatch)
|
72
|
-
@cmd.disable_system = true
|
73
|
-
|
74
|
-
@cmd.scripts "somescript.sql"
|
75
|
-
@cmd.trusted_connection = true
|
76
|
-
@cmd.username = "user"
|
77
|
-
@cmd.password = "password"
|
78
|
-
|
79
|
-
@cmd.execute
|
80
|
-
end
|
81
|
-
|
82
|
-
it "should override the trusted connection and not specify the -E option" do
|
83
|
-
@cmd.system_command.should_not include("-E")
|
84
|
-
end
|
85
|
-
|
86
|
-
it "should specify the username" do
|
87
|
-
@cmd.system_command.should include("-U \"user\"")
|
88
|
-
end
|
89
|
-
|
90
|
-
it "should specify the password" do
|
91
|
-
@cmd.system_command.should include("-P \"password\"")
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
describe SQLCmd, "when running a script file against a database with authentication information" do
|
96
|
-
before :all do
|
97
|
-
@cmd = SQLCmd.new
|
98
|
-
@cmd.command = "sqlcmd.exe"
|
99
|
-
@cmd.log_level = :verbose
|
100
|
-
@cmd.extend(SystemPatch)
|
101
|
-
@cmd.disable_system = true
|
102
|
-
|
103
|
-
@cmd.server="a server"
|
104
|
-
@cmd.database="a database"
|
105
|
-
@cmd.username="some user"
|
106
|
-
@cmd.password="shh! it's a secret!"
|
107
|
-
@cmd.scripts "somescript.sql"
|
108
|
-
|
109
|
-
@cmd.execute
|
110
|
-
end
|
111
|
-
|
112
|
-
it "should specify the location of the sqlcmd exe" do
|
113
|
-
@cmd.system_command.downcase.should include("sqlcmd.exe")
|
114
|
-
end
|
115
|
-
|
116
|
-
it "should specify the script file" do
|
117
|
-
@cmd.system_command.should include("-i \"somescript.sql\"")
|
118
|
-
end
|
119
|
-
|
120
|
-
it "should specify the server" do
|
121
|
-
@cmd.system_command.should include("-S \"a server\"")
|
122
|
-
end
|
123
|
-
|
124
|
-
it "should specify the database" do
|
125
|
-
@cmd.system_command.should include("-d \"a database\"")
|
126
|
-
end
|
127
|
-
|
128
|
-
it "should specify the username" do
|
129
|
-
@cmd.system_command.should include("-U \"some user\"")
|
130
|
-
end
|
131
|
-
|
132
|
-
it "should specify the password" do
|
133
|
-
@cmd.system_command.should include("-P \"shh! it's a secret!\"")
|
134
|
-
end
|
135
|
-
|
136
|
-
it "should not contain the -b option" do
|
137
|
-
@cmd.system_command.should_not include("-b")
|
138
|
-
end
|
139
|
-
end
|
140
|
-
|
141
|
-
describe SQLCmd, "when running with no command path specified" do
|
142
|
-
before :all do
|
143
|
-
strio = StringIO.new
|
144
|
-
@cmd = SQLCmd.new
|
145
|
-
@cmd.log_level = :verbose
|
146
|
-
@cmd.log_device = strio
|
147
|
-
@cmd.extend(SystemPatch)
|
148
|
-
@cmd.extend(FailPatch)
|
149
|
-
@cmd.disable_system = true
|
150
|
-
|
151
|
-
@cmd.execute
|
152
|
-
@log_data = strio.string
|
153
|
-
|
154
|
-
@all_possible_sqlcmd_paths = []
|
155
|
-
|
156
|
-
["program files", "program files (x86)"].each do |program_files|
|
157
|
-
["90", "100"].each do |sql_version|
|
158
|
-
sqlcmd_path = File.join(ENV['SystemDrive'], program_files,'microsoft sql server', sql_version, 'tools','binn', 'sqlcmd.exe')
|
159
|
-
@all_possible_sqlcmd_paths << sqlcmd_path
|
160
|
-
end
|
161
|
-
end
|
162
|
-
end
|
163
|
-
|
164
|
-
it "should find sqlcmd in the standard places or bail" do
|
165
|
-
any_sqlcmd_exists = false
|
166
|
-
|
167
|
-
@all_possible_sqlcmd_paths.each do |sqlcmd_path|
|
168
|
-
sqlcmd_exists = File.exists?(sqlcmd_path)
|
169
|
-
any_sqlcmd_exists = true if sqlcmd_exists
|
170
|
-
$task_failed.should be_false if sqlcmd_exists
|
171
|
-
end
|
172
|
-
$task_failed.should be_true if any_sqlcmd_exists == false
|
173
|
-
end
|
174
|
-
|
175
|
-
it "should log a failure message if it cannot find sqlcmd in the standard places" do
|
176
|
-
any_sqlcmd_exists = false
|
177
|
-
|
178
|
-
@all_possible_sqlcmd_paths.each do |sqlcmd_path|
|
179
|
-
sqlcmd_exists = File.exists?(sqlcmd_path)
|
180
|
-
any_sqlcmd_exists = true if File.exists?(sqlcmd_path)
|
181
|
-
end
|
182
|
-
@log_data.should include('SQLCmd.command cannot be nil.') if any_sqlcmd_exists == false
|
183
|
-
end
|
184
|
-
end
|
185
|
-
|
186
|
-
describe SQLCmd, "when execution of sqlcmd fails" do
|
187
|
-
before :all do
|
188
|
-
strio = StringIO.new
|
189
|
-
@cmd = SQLCmd.new
|
190
|
-
@cmd.command="sqlcmd.exe"
|
191
|
-
@cmd.log_level = :verbose
|
192
|
-
@cmd.log_device = strio
|
193
|
-
@cmd.extend(SystemPatch)
|
194
|
-
@cmd.extend(FailPatch)
|
195
|
-
@cmd.disable_system = true
|
196
|
-
@cmd.force_system_failure = true
|
197
|
-
|
198
|
-
@cmd.execute
|
199
|
-
@log_data = strio.string
|
200
|
-
end
|
201
|
-
|
202
|
-
|
203
|
-
it "should fail" do
|
204
|
-
$task_failed.should be_true
|
205
|
-
end
|
206
|
-
|
207
|
-
it "should log a failure message" do
|
208
|
-
@log_data.should include('SQLCmd Failed. See Build Log For Detail.')
|
209
|
-
end
|
210
|
-
end
|
211
|
-
|
212
|
-
describe SQLCmd, "when running multiple script files" do
|
213
|
-
before :all do
|
214
|
-
@cmd = SQLCmd.new
|
215
|
-
@cmd.command = "sqlcmd.exe"
|
216
|
-
@cmd.log_level = :verbose
|
217
|
-
@cmd.extend(SystemPatch)
|
218
|
-
@cmd.disable_system = true
|
219
|
-
|
220
|
-
scriptnames = Array.new
|
221
|
-
scriptnames << "did you get.sql\r\n"
|
222
|
-
scriptnames << "that thing.sql"
|
223
|
-
scriptnames << "i sent you.sql\r\n"
|
224
|
-
@cmd.scripts = scriptnames
|
225
|
-
|
226
|
-
@cmd.execute
|
227
|
-
end
|
228
|
-
|
229
|
-
it "should specify the first script file" do
|
230
|
-
@cmd.system_command.should include("-i \"did you get.sql\"")
|
231
|
-
end
|
232
|
-
|
233
|
-
it "should specify the second script file" do
|
234
|
-
@cmd.system_command.should include("-i \"that thing.sql\"")
|
235
|
-
end
|
236
|
-
|
237
|
-
it "should specify the third script file" do
|
238
|
-
@cmd.system_command.should include("-i \"i sent you.sql\"")
|
239
|
-
end
|
240
|
-
|
241
|
-
it "should include the -b option" do
|
242
|
-
@cmd.system_command.should include("-b")
|
243
|
-
end
|
244
|
-
|
245
|
-
end
|
246
|
-
|
247
|
-
describe SQLCmd, "when running multiple script files with batch_abort set to false" do
|
248
|
-
before :all do
|
249
|
-
@cmd = SQLCmd.new
|
250
|
-
@cmd.command = "sqlcmd.exe"
|
251
|
-
@cmd.log_level = :verbose
|
252
|
-
@cmd.extend(SystemPatch)
|
253
|
-
@cmd.disable_system = true
|
254
|
-
@cmd.batch_abort = false
|
255
|
-
|
256
|
-
scriptnames = Array.new
|
257
|
-
scriptnames << "did you get.sql\r\n"
|
258
|
-
scriptnames << "that thing.sql"
|
259
|
-
scriptnames << "i sent you.sql\r\n"
|
260
|
-
@cmd.scripts = scriptnames
|
261
|
-
|
262
|
-
@cmd.execute
|
263
|
-
end
|
264
|
-
|
265
|
-
it "should specify the first script file" do
|
266
|
-
@cmd.system_command.should include("-i \"did you get.sql\"")
|
267
|
-
end
|
268
|
-
|
269
|
-
it "should specify the second script file" do
|
270
|
-
@cmd.system_command.should include("-i \"that thing.sql\"")
|
271
|
-
end
|
272
|
-
|
273
|
-
it "should specify the third script file" do
|
274
|
-
@cmd.system_command.should include("-i \"i sent you.sql\"")
|
275
|
-
end
|
276
|
-
|
277
|
-
it "should not include the -b option" do
|
278
|
-
@cmd.system_command.should_not include("-b")
|
279
|
-
end
|
280
|
-
|
281
|
-
end
|
282
|
-
|
283
|
-
describe SQLCmd, "when running with variables specified" do
|
284
|
-
before :all do
|
285
|
-
@cmd = SQLCmd.new
|
286
|
-
@cmd.command = "sqlcmd.exe"
|
287
|
-
@cmd.log_level = :verbose
|
288
|
-
@cmd.extend(SystemPatch)
|
289
|
-
@cmd.disable_system = true
|
290
|
-
@cmd.scripts "somescript.sql"
|
291
|
-
|
292
|
-
@cmd.variables :myvar => "my value", :another_var => :another_value
|
293
|
-
|
294
|
-
@cmd.execute
|
295
|
-
end
|
296
|
-
|
297
|
-
it "should supply the variables to sqlcmd" do
|
298
|
-
@cmd.system_command.should include("-v myvar=my value")
|
299
|
-
@cmd.system_command.should include("-v another_var=another_value")
|
300
|
-
end
|
301
|
-
end
|
302
|
-
|
303
|
-
describe SQLCmd, "when providing configuration" do
|
304
|
-
let :sqlcmd do
|
305
|
-
Albacore.configure do |config|
|
306
|
-
config.sqlcmd.command = "configured"
|
307
|
-
end
|
308
|
-
sqlcmd = SQLCmd.new
|
309
|
-
end
|
310
|
-
|
311
|
-
it "should use the configured values" do
|
312
|
-
sqlcmd.command.should == "configured"
|
313
|
-
end
|
314
|
-
end
|
315
|
-
|
316
|
-
describe SQLCmd, "when severity it set" do
|
317
|
-
before :all do
|
318
|
-
@cmd = SQLCmd.new
|
319
|
-
@cmd.extend(SystemPatch)
|
320
|
-
@cmd.disable_system = true
|
321
|
-
@cmd.scripts "somescript.sql"
|
322
|
-
|
323
|
-
@cmd.severity = 1
|
324
|
-
|
325
|
-
@cmd.execute
|
326
|
-
end
|
327
|
-
|
328
|
-
it "should have severity option set" do
|
329
|
-
@cmd.system_command.should include("-V")
|
330
|
-
end
|
331
|
-
it "should have severity set to correct value" do
|
332
|
-
@cmd.system_command.should include("-V \"1\"")
|
333
|
-
end
|
334
|
-
end
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'albacore/sqlcmd'
|
3
|
+
|
4
|
+
describe SQLCmd, "when running a script the easy way" do
|
5
|
+
before :all do
|
6
|
+
@cmd = SQLCmd.new
|
7
|
+
@cmd.log_level = :verbose
|
8
|
+
@cmd.extend(SystemPatch)
|
9
|
+
@cmd.disable_system = true
|
10
|
+
|
11
|
+
@cmd.scripts "somescript.sql"
|
12
|
+
|
13
|
+
@cmd.execute
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should use localhost as server default" do
|
17
|
+
@cmd.system_command.should include("-S \".\"")
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should have no database designation (because it could be embedded in the sql file)" do
|
21
|
+
@cmd.system_command.should_not include("-d")
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should use integrated security instead of username/password" do
|
25
|
+
@cmd.system_command.should include("-E")
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should not include username" do
|
29
|
+
@cmd.system_command.should_not include("-U")
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should not include password" do
|
33
|
+
@cmd.system_command.should_not include("-P")
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should find the location of the sqlcmd exe for the user" do
|
37
|
+
@cmd.system_command.downcase.should include("sqlcmd.exe")
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should specify the script file" do
|
41
|
+
@cmd.system_command.should include("-i \"somescript.sql\"")
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should not contain the -b option" do
|
45
|
+
@cmd.system_command.should_not include("-b")
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe SQLCmd, "when turning off trusted_connection" do
|
50
|
+
before :all do
|
51
|
+
@cmd = SQLCmd.new
|
52
|
+
@cmd.log_level = :verbose
|
53
|
+
@cmd.extend(SystemPatch)
|
54
|
+
@cmd.disable_system = true
|
55
|
+
|
56
|
+
@cmd.scripts "somescript.sql"
|
57
|
+
@cmd.trusted_connection = false
|
58
|
+
|
59
|
+
@cmd.execute
|
60
|
+
end
|
61
|
+
|
62
|
+
it "should not specify the -E option" do
|
63
|
+
@cmd.system_command.should_not include("-E")
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
describe SQLCmd, "when using a trusted connection with a username and password" do
|
68
|
+
before :all do
|
69
|
+
@cmd = SQLCmd.new
|
70
|
+
@cmd.log_level = :verbose
|
71
|
+
@cmd.extend(SystemPatch)
|
72
|
+
@cmd.disable_system = true
|
73
|
+
|
74
|
+
@cmd.scripts "somescript.sql"
|
75
|
+
@cmd.trusted_connection = true
|
76
|
+
@cmd.username = "user"
|
77
|
+
@cmd.password = "password"
|
78
|
+
|
79
|
+
@cmd.execute
|
80
|
+
end
|
81
|
+
|
82
|
+
it "should override the trusted connection and not specify the -E option" do
|
83
|
+
@cmd.system_command.should_not include("-E")
|
84
|
+
end
|
85
|
+
|
86
|
+
it "should specify the username" do
|
87
|
+
@cmd.system_command.should include("-U \"user\"")
|
88
|
+
end
|
89
|
+
|
90
|
+
it "should specify the password" do
|
91
|
+
@cmd.system_command.should include("-P \"password\"")
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
describe SQLCmd, "when running a script file against a database with authentication information" do
|
96
|
+
before :all do
|
97
|
+
@cmd = SQLCmd.new
|
98
|
+
@cmd.command = "sqlcmd.exe"
|
99
|
+
@cmd.log_level = :verbose
|
100
|
+
@cmd.extend(SystemPatch)
|
101
|
+
@cmd.disable_system = true
|
102
|
+
|
103
|
+
@cmd.server="a server"
|
104
|
+
@cmd.database="a database"
|
105
|
+
@cmd.username="some user"
|
106
|
+
@cmd.password="shh! it's a secret!"
|
107
|
+
@cmd.scripts "somescript.sql"
|
108
|
+
|
109
|
+
@cmd.execute
|
110
|
+
end
|
111
|
+
|
112
|
+
it "should specify the location of the sqlcmd exe" do
|
113
|
+
@cmd.system_command.downcase.should include("sqlcmd.exe")
|
114
|
+
end
|
115
|
+
|
116
|
+
it "should specify the script file" do
|
117
|
+
@cmd.system_command.should include("-i \"somescript.sql\"")
|
118
|
+
end
|
119
|
+
|
120
|
+
it "should specify the server" do
|
121
|
+
@cmd.system_command.should include("-S \"a server\"")
|
122
|
+
end
|
123
|
+
|
124
|
+
it "should specify the database" do
|
125
|
+
@cmd.system_command.should include("-d \"a database\"")
|
126
|
+
end
|
127
|
+
|
128
|
+
it "should specify the username" do
|
129
|
+
@cmd.system_command.should include("-U \"some user\"")
|
130
|
+
end
|
131
|
+
|
132
|
+
it "should specify the password" do
|
133
|
+
@cmd.system_command.should include("-P \"shh! it's a secret!\"")
|
134
|
+
end
|
135
|
+
|
136
|
+
it "should not contain the -b option" do
|
137
|
+
@cmd.system_command.should_not include("-b")
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
describe SQLCmd, "when running with no command path specified" do
|
142
|
+
before :all do
|
143
|
+
strio = StringIO.new
|
144
|
+
@cmd = SQLCmd.new
|
145
|
+
@cmd.log_level = :verbose
|
146
|
+
@cmd.log_device = strio
|
147
|
+
@cmd.extend(SystemPatch)
|
148
|
+
@cmd.extend(FailPatch)
|
149
|
+
@cmd.disable_system = true
|
150
|
+
|
151
|
+
@cmd.execute
|
152
|
+
@log_data = strio.string
|
153
|
+
|
154
|
+
@all_possible_sqlcmd_paths = []
|
155
|
+
|
156
|
+
["program files", "program files (x86)"].each do |program_files|
|
157
|
+
["90", "100"].each do |sql_version|
|
158
|
+
sqlcmd_path = File.join(ENV['SystemDrive'], program_files,'microsoft sql server', sql_version, 'tools','binn', 'sqlcmd.exe')
|
159
|
+
@all_possible_sqlcmd_paths << sqlcmd_path
|
160
|
+
end
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
it "should find sqlcmd in the standard places or bail" do
|
165
|
+
any_sqlcmd_exists = false
|
166
|
+
|
167
|
+
@all_possible_sqlcmd_paths.each do |sqlcmd_path|
|
168
|
+
sqlcmd_exists = File.exists?(sqlcmd_path)
|
169
|
+
any_sqlcmd_exists = true if sqlcmd_exists
|
170
|
+
$task_failed.should be_false if sqlcmd_exists
|
171
|
+
end
|
172
|
+
$task_failed.should be_true if any_sqlcmd_exists == false
|
173
|
+
end
|
174
|
+
|
175
|
+
it "should log a failure message if it cannot find sqlcmd in the standard places" do
|
176
|
+
any_sqlcmd_exists = false
|
177
|
+
|
178
|
+
@all_possible_sqlcmd_paths.each do |sqlcmd_path|
|
179
|
+
sqlcmd_exists = File.exists?(sqlcmd_path)
|
180
|
+
any_sqlcmd_exists = true if File.exists?(sqlcmd_path)
|
181
|
+
end
|
182
|
+
@log_data.should include('SQLCmd.command cannot be nil.') if any_sqlcmd_exists == false
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
186
|
+
describe SQLCmd, "when execution of sqlcmd fails" do
|
187
|
+
before :all do
|
188
|
+
strio = StringIO.new
|
189
|
+
@cmd = SQLCmd.new
|
190
|
+
@cmd.command="sqlcmd.exe"
|
191
|
+
@cmd.log_level = :verbose
|
192
|
+
@cmd.log_device = strio
|
193
|
+
@cmd.extend(SystemPatch)
|
194
|
+
@cmd.extend(FailPatch)
|
195
|
+
@cmd.disable_system = true
|
196
|
+
@cmd.force_system_failure = true
|
197
|
+
|
198
|
+
@cmd.execute
|
199
|
+
@log_data = strio.string
|
200
|
+
end
|
201
|
+
|
202
|
+
|
203
|
+
it "should fail" do
|
204
|
+
$task_failed.should be_true
|
205
|
+
end
|
206
|
+
|
207
|
+
it "should log a failure message" do
|
208
|
+
@log_data.should include('SQLCmd Failed. See Build Log For Detail.')
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
212
|
+
describe SQLCmd, "when running multiple script files" do
|
213
|
+
before :all do
|
214
|
+
@cmd = SQLCmd.new
|
215
|
+
@cmd.command = "sqlcmd.exe"
|
216
|
+
@cmd.log_level = :verbose
|
217
|
+
@cmd.extend(SystemPatch)
|
218
|
+
@cmd.disable_system = true
|
219
|
+
|
220
|
+
scriptnames = Array.new
|
221
|
+
scriptnames << "did you get.sql\r\n"
|
222
|
+
scriptnames << "that thing.sql"
|
223
|
+
scriptnames << "i sent you.sql\r\n"
|
224
|
+
@cmd.scripts = scriptnames
|
225
|
+
|
226
|
+
@cmd.execute
|
227
|
+
end
|
228
|
+
|
229
|
+
it "should specify the first script file" do
|
230
|
+
@cmd.system_command.should include("-i \"did you get.sql\"")
|
231
|
+
end
|
232
|
+
|
233
|
+
it "should specify the second script file" do
|
234
|
+
@cmd.system_command.should include("-i \"that thing.sql\"")
|
235
|
+
end
|
236
|
+
|
237
|
+
it "should specify the third script file" do
|
238
|
+
@cmd.system_command.should include("-i \"i sent you.sql\"")
|
239
|
+
end
|
240
|
+
|
241
|
+
it "should include the -b option" do
|
242
|
+
@cmd.system_command.should include("-b")
|
243
|
+
end
|
244
|
+
|
245
|
+
end
|
246
|
+
|
247
|
+
describe SQLCmd, "when running multiple script files with batch_abort set to false" do
|
248
|
+
before :all do
|
249
|
+
@cmd = SQLCmd.new
|
250
|
+
@cmd.command = "sqlcmd.exe"
|
251
|
+
@cmd.log_level = :verbose
|
252
|
+
@cmd.extend(SystemPatch)
|
253
|
+
@cmd.disable_system = true
|
254
|
+
@cmd.batch_abort = false
|
255
|
+
|
256
|
+
scriptnames = Array.new
|
257
|
+
scriptnames << "did you get.sql\r\n"
|
258
|
+
scriptnames << "that thing.sql"
|
259
|
+
scriptnames << "i sent you.sql\r\n"
|
260
|
+
@cmd.scripts = scriptnames
|
261
|
+
|
262
|
+
@cmd.execute
|
263
|
+
end
|
264
|
+
|
265
|
+
it "should specify the first script file" do
|
266
|
+
@cmd.system_command.should include("-i \"did you get.sql\"")
|
267
|
+
end
|
268
|
+
|
269
|
+
it "should specify the second script file" do
|
270
|
+
@cmd.system_command.should include("-i \"that thing.sql\"")
|
271
|
+
end
|
272
|
+
|
273
|
+
it "should specify the third script file" do
|
274
|
+
@cmd.system_command.should include("-i \"i sent you.sql\"")
|
275
|
+
end
|
276
|
+
|
277
|
+
it "should not include the -b option" do
|
278
|
+
@cmd.system_command.should_not include("-b")
|
279
|
+
end
|
280
|
+
|
281
|
+
end
|
282
|
+
|
283
|
+
describe SQLCmd, "when running with variables specified" do
|
284
|
+
before :all do
|
285
|
+
@cmd = SQLCmd.new
|
286
|
+
@cmd.command = "sqlcmd.exe"
|
287
|
+
@cmd.log_level = :verbose
|
288
|
+
@cmd.extend(SystemPatch)
|
289
|
+
@cmd.disable_system = true
|
290
|
+
@cmd.scripts "somescript.sql"
|
291
|
+
|
292
|
+
@cmd.variables :myvar => "my value", :another_var => :another_value
|
293
|
+
|
294
|
+
@cmd.execute
|
295
|
+
end
|
296
|
+
|
297
|
+
it "should supply the variables to sqlcmd" do
|
298
|
+
@cmd.system_command.should include("-v myvar=my value")
|
299
|
+
@cmd.system_command.should include("-v another_var=another_value")
|
300
|
+
end
|
301
|
+
end
|
302
|
+
|
303
|
+
describe SQLCmd, "when providing configuration" do
|
304
|
+
let :sqlcmd do
|
305
|
+
Albacore.configure do |config|
|
306
|
+
config.sqlcmd.command = "configured"
|
307
|
+
end
|
308
|
+
sqlcmd = SQLCmd.new
|
309
|
+
end
|
310
|
+
|
311
|
+
it "should use the configured values" do
|
312
|
+
sqlcmd.command.should == "configured"
|
313
|
+
end
|
314
|
+
end
|
315
|
+
|
316
|
+
describe SQLCmd, "when severity it set" do
|
317
|
+
before :all do
|
318
|
+
@cmd = SQLCmd.new
|
319
|
+
@cmd.extend(SystemPatch)
|
320
|
+
@cmd.disable_system = true
|
321
|
+
@cmd.scripts "somescript.sql"
|
322
|
+
|
323
|
+
@cmd.severity = 1
|
324
|
+
|
325
|
+
@cmd.execute
|
326
|
+
end
|
327
|
+
|
328
|
+
it "should have severity option set" do
|
329
|
+
@cmd.system_command.should include("-V")
|
330
|
+
end
|
331
|
+
it "should have severity set to correct value" do
|
332
|
+
@cmd.system_command.should include("-V \"1\"")
|
333
|
+
end
|
334
|
+
end
|