tiny_tds 2.1.2 → 2.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.circleci/config.yml +409 -0
- data/.gitignore +2 -0
- data/CHANGELOG.md +29 -1
- data/Gemfile +0 -7
- data/README.md +33 -22
- data/Rakefile +19 -10
- data/VERSION +1 -1
- data/docker-compose.yml +34 -0
- data/ext/tiny_tds/client.c +92 -44
- data/ext/tiny_tds/client.h +5 -3
- data/ext/tiny_tds/extconf.rb +38 -15
- data/ext/tiny_tds/extconsts.rb +2 -2
- data/ext/tiny_tds/result.c +25 -10
- data/lib/tiny_tds/gem.rb +1 -6
- data/setup_cimgruby_dev.sh +25 -0
- data/start_dev.sh +21 -0
- data/tasks/native_gem.rake +15 -6
- data/tasks/ports/libiconv.rb +0 -17
- data/tasks/ports/openssl.rb +2 -18
- data/tasks/ports/recipe.rb +16 -4
- data/tasks/ports.rake +61 -40
- data/test/bin/install-mssql.ps1 +31 -0
- data/test/bin/install-mssqltools.sh +9 -0
- data/test/bin/setup_tinytds_db.sh +7 -0
- data/test/bin/setup_volume_permissions.sh +10 -0
- data/test/client_test.rb +99 -54
- data/test/gem_test.rb +26 -28
- data/test/result_test.rb +83 -42
- data/test/schema_test.rb +12 -12
- data/test/sql/db-create.sql +18 -0
- data/test/sql/db-login.sql +38 -0
- data/test/test_helper.rb +67 -4
- data/test/thread_test.rb +1 -1
- data/tiny_tds.gemspec +8 -6
- metadata +54 -45
- data/.travis.yml +0 -24
- data/BACKERS.md +0 -32
- data/appveyor.yml +0 -51
- data/test/appveyor/dbsetup.ps1 +0 -27
- data/test/appveyor/dbsetup.sql +0 -9
- data/test/bin/setup.sh +0 -19
data/tasks/ports/recipe.rb
CHANGED
@@ -5,17 +5,30 @@ require 'rbconfig'
|
|
5
5
|
|
6
6
|
module Ports
|
7
7
|
class Recipe < MiniPortile
|
8
|
+
attr_writer :gem_platform
|
9
|
+
|
8
10
|
def cook
|
9
|
-
checkpoint = "ports/#{name}-#{version}-#{
|
11
|
+
checkpoint = "ports/checkpoints/#{name}-#{version}-#{gem_platform}.installed"
|
10
12
|
|
11
13
|
unless File.exist? checkpoint
|
12
14
|
super
|
15
|
+
FileUtils.mkdir_p("ports/checkpoints")
|
13
16
|
FileUtils.touch checkpoint
|
14
17
|
end
|
15
18
|
end
|
16
19
|
|
17
20
|
private
|
18
21
|
|
22
|
+
attr_reader :gem_platform
|
23
|
+
|
24
|
+
def port_path
|
25
|
+
"#{@target}/#{gem_platform}/#{@name}/#{@version}"
|
26
|
+
end
|
27
|
+
|
28
|
+
def tmp_path
|
29
|
+
"tmp/#{gem_platform}/ports/#{@name}/#{@version}"
|
30
|
+
end
|
31
|
+
|
19
32
|
def configure_defaults
|
20
33
|
[
|
21
34
|
"--host=#{@host}",
|
@@ -38,9 +51,9 @@ module Ports
|
|
38
51
|
|
39
52
|
def get_patches(libname, version)
|
40
53
|
patches = []
|
41
|
-
|
54
|
+
|
42
55
|
patch_path = File.expand_path(
|
43
|
-
File.join('..','..','..','patches',libname,version),
|
56
|
+
File.join('..','..','..','patches',libname,version),
|
44
57
|
__FILE__
|
45
58
|
)
|
46
59
|
|
@@ -49,4 +62,3 @@ module Ports
|
|
49
62
|
end
|
50
63
|
end
|
51
64
|
end
|
52
|
-
|
data/tasks/ports.rake
CHANGED
@@ -6,64 +6,70 @@ require_relative 'ports/openssl'
|
|
6
6
|
require_relative 'ports/freetds'
|
7
7
|
require_relative '../ext/tiny_tds/extconsts'
|
8
8
|
|
9
|
-
OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE if defined? OpenSSL
|
10
|
-
|
11
9
|
namespace :ports do
|
12
|
-
|
13
|
-
|
14
|
-
|
10
|
+
libraries_to_compile = {
|
11
|
+
openssl: Ports::Openssl.new(OPENSSL_VERSION),
|
12
|
+
libiconv: Ports::Libiconv.new(ICONV_VERSION),
|
13
|
+
freetds: Ports::Freetds.new(FREETDS_VERSION)
|
14
|
+
}
|
15
15
|
|
16
16
|
directory "ports"
|
17
|
+
CLEAN.include "ports/*mingw*"
|
18
|
+
CLEAN.include "ports/*.installed"
|
19
|
+
|
20
|
+
task :openssl, [:host, :gem_platform] do |_task, args|
|
21
|
+
args.with_defaults(host: RbConfig::CONFIG['host'], gem_platform: RbConfig::CONFIG["arch"])
|
17
22
|
|
18
|
-
|
19
|
-
|
23
|
+
libraries_to_compile[:openssl].files = [OPENSSL_SOURCE_URI]
|
24
|
+
libraries_to_compile[:openssl].host = args.host
|
25
|
+
libraries_to_compile[:openssl].gem_platform = args.gem_platform
|
20
26
|
|
21
|
-
openssl.
|
22
|
-
openssl.
|
23
|
-
openssl.cook
|
24
|
-
openssl.activate
|
27
|
+
libraries_to_compile[:openssl].cook
|
28
|
+
libraries_to_compile[:openssl].activate
|
25
29
|
end
|
26
30
|
|
27
|
-
task :libiconv, [:host] do |
|
28
|
-
args.with_defaults(host: RbConfig::CONFIG['host'])
|
31
|
+
task :libiconv, [:host, :gem_platform] do |_task, args|
|
32
|
+
args.with_defaults(host: RbConfig::CONFIG['host'], gem_platform: RbConfig::CONFIG["arch"])
|
29
33
|
|
30
|
-
libiconv.files = [ICONV_SOURCE_URI]
|
31
|
-
libiconv.host = args.host
|
32
|
-
libiconv.
|
33
|
-
libiconv.
|
34
|
+
libraries_to_compile[:libiconv].files = [ICONV_SOURCE_URI]
|
35
|
+
libraries_to_compile[:libiconv].host = args.host
|
36
|
+
libraries_to_compile[:libiconv].gem_platform = args.gem_platform
|
37
|
+
libraries_to_compile[:libiconv].cook
|
38
|
+
libraries_to_compile[:libiconv].activate
|
34
39
|
end
|
35
40
|
|
36
|
-
task :freetds, [:host] do |
|
37
|
-
args.with_defaults(host: RbConfig::CONFIG['host'])
|
41
|
+
task :freetds, [:host, :gem_platform] do |_task, args|
|
42
|
+
args.with_defaults(host: RbConfig::CONFIG['host'], gem_platform: RbConfig::CONFIG["arch"])
|
38
43
|
|
39
|
-
freetds.files = [FREETDS_SOURCE_URI]
|
40
|
-
freetds.host = args.host
|
44
|
+
libraries_to_compile[:freetds].files = [FREETDS_SOURCE_URI]
|
45
|
+
libraries_to_compile[:freetds].host = args.host
|
46
|
+
libraries_to_compile[:freetds].gem_platform = args.gem_platform
|
41
47
|
|
42
|
-
if openssl
|
48
|
+
if libraries_to_compile[:openssl]
|
43
49
|
# freetds doesn't have an option that will provide an rpath
|
44
50
|
# so we do it manually
|
45
|
-
ENV['OPENSSL_CFLAGS'] = "-Wl,-rpath -Wl,#{openssl.path}/lib"
|
51
|
+
ENV['OPENSSL_CFLAGS'] = "-Wl,-rpath -Wl,#{libraries_to_compile[:openssl].path}/lib"
|
46
52
|
# Add the pkgconfig file with MSYS2'ish path, to prefer our ports build
|
47
53
|
# over MSYS2 system OpenSSL.
|
48
|
-
ENV['PKG_CONFIG_PATH'] = "#{openssl.path.gsub(/^(\w):/i){"/"
|
49
|
-
freetds.configure_options << "--with-openssl=#{openssl.path}"
|
54
|
+
ENV['PKG_CONFIG_PATH'] = "#{libraries_to_compile[:openssl].path.gsub(/^(\w):/i) { "/" + $1.downcase }}/lib/pkgconfig:#{ENV['PKG_CONFIG_PATH']}"
|
55
|
+
libraries_to_compile[:freetds].configure_options << "--with-openssl=#{libraries_to_compile[:openssl].path}"
|
50
56
|
end
|
51
57
|
|
52
|
-
if libiconv
|
53
|
-
freetds.configure_options << "--with-libiconv-prefix=#{libiconv.path}"
|
58
|
+
if libraries_to_compile[:libiconv]
|
59
|
+
libraries_to_compile[:freetds].configure_options << "--with-libiconv-prefix=#{libraries_to_compile[:libiconv].path}"
|
54
60
|
end
|
55
61
|
|
56
|
-
freetds.cook
|
57
|
-
freetds.activate
|
62
|
+
libraries_to_compile[:freetds].cook
|
63
|
+
libraries_to_compile[:freetds].activate
|
58
64
|
end
|
59
65
|
|
60
|
-
task :compile, [:host] do |
|
61
|
-
args.with_defaults(host: RbConfig::CONFIG['host'])
|
66
|
+
task :compile, [:host, :gem_platform] do |_task, args|
|
67
|
+
args.with_defaults(host: RbConfig::CONFIG['host'], gem_platform: RbConfig::CONFIG["arch"])
|
62
68
|
|
63
|
-
puts "Compiling ports for #{args.host}..."
|
69
|
+
puts "Compiling ports for #{args.host} (Ruby platform #{args.gem_platform}) ..."
|
64
70
|
|
65
|
-
|
66
|
-
Rake::Task["ports:#{lib}"].invoke(args.host)
|
71
|
+
libraries_to_compile.keys.each do |lib|
|
72
|
+
Rake::Task["ports:#{lib}"].invoke(args.host, args.gem_platform)
|
67
73
|
end
|
68
74
|
end
|
69
75
|
|
@@ -71,15 +77,30 @@ namespace :ports do
|
|
71
77
|
task 'cross' do
|
72
78
|
require 'rake_compiler_dock'
|
73
79
|
|
74
|
-
# make sure to install our bundle
|
75
|
-
build = ['bundle']
|
76
|
-
|
77
80
|
# build the ports for all our cross compile hosts
|
78
|
-
GEM_PLATFORM_HOSTS.each do |gem_platform,
|
79
|
-
|
81
|
+
GEM_PLATFORM_HOSTS.each do |gem_platform, meta|
|
82
|
+
# make sure to install our bundle
|
83
|
+
build = ['bundle']
|
84
|
+
build << "RUBY_CC_VERSION=#{meta[:ruby_versions]} rake ports:compile[#{meta[:host]},#{gem_platform}] MAKE='make -j`nproc`'"
|
85
|
+
RakeCompilerDock.sh build.join(' && '), platform: gem_platform
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
desc "Notes the actual versions for the compiled ports into a file"
|
90
|
+
task "version_file", [:gem_platform] do |_task, args|
|
91
|
+
args.with_defaults(gem_platform: RbConfig::CONFIG["arch"])
|
92
|
+
|
93
|
+
ports_version = {}
|
94
|
+
|
95
|
+
libraries_to_compile.each do |library, library_recipe|
|
96
|
+
ports_version[library] = library_recipe.version
|
80
97
|
end
|
81
98
|
|
82
|
-
|
99
|
+
ports_version[:platform] = args.gem_platform
|
100
|
+
|
101
|
+
File.open(".ports_versions", "w") do |f|
|
102
|
+
f.write ports_version
|
103
|
+
end
|
83
104
|
end
|
84
105
|
end
|
85
106
|
|
@@ -0,0 +1,31 @@
|
|
1
|
+
$ProgressPreference = 'SilentlyContinue'
|
2
|
+
|
3
|
+
if (-not(Test-path "C:\Downloads"))
|
4
|
+
{
|
5
|
+
mkdir "C:\Downloads"
|
6
|
+
}
|
7
|
+
|
8
|
+
$sqlInstallationFile = "C:\Downloads\sqlexpress.exe"
|
9
|
+
if (-not(Test-path $sqlInstallationFile -PathType leaf))
|
10
|
+
{
|
11
|
+
Write-Host "Downloading SQL Express ..."
|
12
|
+
Invoke-WebRequest -Uri "https://go.microsoft.com/fwlink/?linkid=829176" -OutFile "C:\Downloads\sqlexpress.exe"
|
13
|
+
}
|
14
|
+
|
15
|
+
Write-Host "Installing SQL Express ..."
|
16
|
+
Start-Process -Wait -FilePath "C:\Downloads\sqlexpress.exe" -ArgumentList /qs, /x:"C:\Downloads\setup"
|
17
|
+
C:\Downloads\setup\setup.exe /q /ACTION=Install /INSTANCENAME=SQLEXPRESS /FEATURES=SQLEngine /UPDATEENABLED=0 /SQLSVCACCOUNT='NT AUTHORITY\System' /SQLSYSADMINACCOUNTS='BUILTIN\ADMINISTRATORS' /TCPENABLED=1 /NPENABLED=0 /IACCEPTSQLSERVERLICENSETERMS
|
18
|
+
|
19
|
+
Write-Host "Configuring SQL Express ..."
|
20
|
+
stop-service MSSQL`$SQLEXPRESS
|
21
|
+
set-itemproperty -path 'HKLM:\software\microsoft\microsoft sql server\mssql14.SQLEXPRESS\mssqlserver\supersocketnetlib\tcp\ipall' -name tcpdynamicports -value ''
|
22
|
+
set-itemproperty -path 'HKLM:\software\microsoft\microsoft sql server\mssql14.SQLEXPRESS\mssqlserver\supersocketnetlib\tcp\ipall' -name tcpport -value 1433
|
23
|
+
set-itemproperty -path 'HKLM:\software\microsoft\microsoft sql server\mssql14.SQLEXPRESS\mssqlserver\' -name LoginMode -value 2
|
24
|
+
|
25
|
+
Write-Host "Starting SQL Express ..."
|
26
|
+
start-service MSSQL`$SQLEXPRESS
|
27
|
+
|
28
|
+
Write-Host "Configuring MSSQL for TinyTDS ..."
|
29
|
+
& sqlcmd -Q "CREATE DATABASE [tinytdstest];"
|
30
|
+
& sqlcmd -Q "CREATE LOGIN [tinytds] WITH PASSWORD = '', CHECK_POLICY = OFF, DEFAULT_DATABASE = [tinytdstest];"
|
31
|
+
& sqlcmd -Q "USE [tinytdstest]; CREATE USER [tinytds] FOR LOGIN [tinytds]; EXEC sp_addrolemember N'db_owner', N'tinytds';"
|
@@ -0,0 +1,9 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
|
3
|
+
set -x
|
4
|
+
set -e
|
5
|
+
|
6
|
+
curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
|
7
|
+
curl https://packages.microsoft.com/config/ubuntu/20.04/prod.list | sudo tee /etc/apt/sources.list.d/msprod.list
|
8
|
+
sudo apt-get update
|
9
|
+
sudo ACCEPT_EULA=Y apt-get -y install mssql-tools unixodbc-dev
|
@@ -0,0 +1,10 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
|
3
|
+
set -x
|
4
|
+
|
5
|
+
sudo groupadd -g 3434 circleci_tinytds
|
6
|
+
sudo usermod -a -G circleci_tinytds $USER
|
7
|
+
sudo useradd circleci_tinytds -u 3434 -g 3434
|
8
|
+
sudo usermod -a -G circleci_tinytds circleci_tinytds
|
9
|
+
sudo chgrp -R circleci_tinytds .
|
10
|
+
sudo chmod -R g+rwx .
|
data/test/client_test.rb
CHANGED
@@ -2,9 +2,7 @@
|
|
2
2
|
require 'test_helper'
|
3
3
|
|
4
4
|
class ClientTest < TinyTds::TestCase
|
5
|
-
|
6
|
-
describe 'With valid credentials' do
|
7
|
-
|
5
|
+
describe 'with valid credentials' do
|
8
6
|
before do
|
9
7
|
@client = new_connection
|
10
8
|
end
|
@@ -18,6 +16,7 @@ class ClientTest < TinyTds::TestCase
|
|
18
16
|
assert @client.close
|
19
17
|
assert @client.closed?
|
20
18
|
assert !@client.active?
|
19
|
+
assert @client.dead?
|
21
20
|
action = lambda { @client.execute('SELECT 1 as [one]').each }
|
22
21
|
assert_raise_tinytds_error(action) do |e|
|
23
22
|
assert_match %r{closed connection}i, e.message, 'ignore if non-english test run'
|
@@ -67,10 +66,12 @@ class ClientTest < TinyTds::TestCase
|
|
67
66
|
client.close if client
|
68
67
|
end
|
69
68
|
end unless sqlserver_azure?
|
70
|
-
|
71
69
|
end
|
72
70
|
|
73
71
|
describe 'With in-valid options' do
|
72
|
+
before(:all) do
|
73
|
+
init_toxiproxy
|
74
|
+
end
|
74
75
|
|
75
76
|
it 'raises an argument error when no :host given and :dataserver is blank' do
|
76
77
|
assert_raises(ArgumentError) { new_connection :dataserver => nil, :host => nil }
|
@@ -132,30 +133,63 @@ class ClientTest < TinyTds::TestCase
|
|
132
133
|
end
|
133
134
|
end
|
134
135
|
|
135
|
-
it '
|
136
|
-
skip
|
136
|
+
it 'raises TinyTds exception with tcp socket network failure' do
|
137
137
|
begin
|
138
|
-
client = new_connection :
|
138
|
+
client = new_connection timeout: 2, port: 1234, host: ENV['TOXIPROXY_HOST']
|
139
139
|
assert_client_works(client)
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
140
|
+
action = lambda { client.execute("waitfor delay '00:00:05'").do }
|
141
|
+
|
142
|
+
# Use toxiproxy to close the TCP socket after 1 second.
|
143
|
+
# We want TinyTds to execute the statement, hit the timeout configured above, and then not be able to use the network to cancel
|
144
|
+
# the network connection needs to close after the sql batch is sent and before the timeout above is hit
|
145
|
+
Toxiproxy[:sqlserver_test].toxic(:slow_close, delay: 1000).apply do
|
146
|
+
assert_raise_tinytds_error(action) do |e|
|
147
|
+
assert_equal 20003, e.db_error_number
|
148
|
+
assert_equal 6, e.severity
|
149
|
+
assert_match %r{timed out}i, e.message, 'ignore if non-english test run'
|
150
|
+
end
|
151
|
+
end
|
152
|
+
ensure
|
153
|
+
assert_new_connections_work
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
it 'raises TinyTds exception with dead connection network failure' do
|
158
|
+
skip if ruby_windows?
|
159
|
+
|
160
|
+
begin
|
161
|
+
client = new_connection timeout: 2, port: 1234, host: ENV['TOXIPROXY_HOST']
|
162
|
+
assert_client_works(client)
|
163
|
+
action = lambda { client.execute("waitfor delay '00:00:05'").do }
|
164
|
+
|
165
|
+
# Use toxiproxy to close the network connection after 1 second.
|
166
|
+
# We want TinyTds to execute the statement, hit the timeout configured above, and then not be able to use the network to cancel
|
167
|
+
# the network connection needs to close after the sql batch is sent and before the timeout above is hit
|
168
|
+
Toxiproxy[:sqlserver_test].toxic(:timeout, timeout: 1000).apply do
|
169
|
+
assert_raise_tinytds_error(action) do |e|
|
170
|
+
assert_equal 20047, e.db_error_number
|
171
|
+
assert_includes [1,9], e.severity
|
172
|
+
assert_match %r{dead or not enabled}i, e.message, 'ignore if non-english test run'
|
173
|
+
end
|
174
|
+
end
|
175
|
+
ensure
|
176
|
+
assert_new_connections_work
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
180
|
+
it 'raises TinyTds exception with login timeout' do
|
181
|
+
begin
|
182
|
+
action = lambda do
|
183
|
+
Toxiproxy[:sqlserver_test].toxic(:timeout, timeout: 0).apply do
|
184
|
+
new_connection login_timeout: 1, port: 1234, host: ENV['TOXIPROXY_HOST']
|
185
|
+
end
|
186
|
+
end
|
144
187
|
assert_raise_tinytds_error(action) do |e|
|
145
188
|
assert_equal 20003, e.db_error_number
|
146
189
|
assert_equal 6, e.severity
|
147
190
|
assert_match %r{timed out}i, e.message, 'ignore if non-english test run'
|
148
191
|
end
|
149
192
|
ensure
|
150
|
-
STDOUT.puts "Reconnect network!"
|
151
|
-
sleep 10
|
152
|
-
action = lambda { client.execute('SELECT 1 as [one]').each }
|
153
|
-
assert_raise_tinytds_error(action) do |e|
|
154
|
-
assert_equal 20047, e.db_error_number
|
155
|
-
assert_equal 1, e.severity
|
156
|
-
assert_match %r{dead or not enabled}i, e.message, 'ignore if non-english test run'
|
157
|
-
end
|
158
|
-
close_client(client)
|
159
193
|
assert_new_connections_work
|
160
194
|
end
|
161
195
|
end
|
@@ -174,57 +208,68 @@ class ClientTest < TinyTds::TestCase
|
|
174
208
|
|
175
209
|
end
|
176
210
|
|
177
|
-
describe '
|
178
|
-
|
211
|
+
describe '#parse_username' do
|
179
212
|
let(:client) { @client = new_connection }
|
180
213
|
|
181
|
-
it '
|
182
|
-
|
183
|
-
|
214
|
+
it 'returns username if azure is not true' do
|
215
|
+
_(
|
216
|
+
client.send(:parse_username, username: 'user@abc123.database.windows.net')
|
217
|
+
).must_equal 'user@abc123.database.windows.net'
|
184
218
|
end
|
185
219
|
|
186
|
-
it '
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
220
|
+
it 'returns short username if azure is true' do
|
221
|
+
_(
|
222
|
+
client.send(
|
223
|
+
:parse_username,
|
224
|
+
username: 'user@abc123.database.windows.net',
|
225
|
+
host: 'abc123.database.windows.net',
|
226
|
+
azure: true
|
227
|
+
)
|
191
228
|
).must_equal 'user@abc123'
|
192
229
|
end
|
193
230
|
|
194
|
-
it '
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
231
|
+
it 'returns full username if azure is false' do
|
232
|
+
_(
|
233
|
+
client.send(
|
234
|
+
:parse_username,
|
235
|
+
username: 'user@abc123.database.windows.net',
|
236
|
+
host: 'abc123.database.windows.net',
|
237
|
+
azure: false
|
238
|
+
)
|
199
239
|
).must_equal 'user@abc123.database.windows.net'
|
200
240
|
end
|
201
241
|
|
202
|
-
it '
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
242
|
+
it 'returns short username if passed and azure is true' do
|
243
|
+
_(
|
244
|
+
client.send(
|
245
|
+
:parse_username,
|
246
|
+
username: 'user@abc123',
|
247
|
+
host: 'abc123.database.windows.net',
|
248
|
+
azure: true
|
249
|
+
)
|
207
250
|
).must_equal 'user@abc123'
|
208
251
|
end
|
209
252
|
|
210
|
-
it '
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
253
|
+
it 'returns username with servername if passed and azure is true' do
|
254
|
+
_(
|
255
|
+
client.send(
|
256
|
+
:parse_username,
|
257
|
+
username: 'user',
|
258
|
+
host: 'abc123.database.windows.net',
|
259
|
+
azure: true
|
260
|
+
)
|
215
261
|
).must_equal 'user@abc123'
|
216
262
|
end
|
217
263
|
|
218
|
-
it '
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
264
|
+
it 'returns username with servername if passed and azure is false' do
|
265
|
+
_(
|
266
|
+
client.send(
|
267
|
+
:parse_username,
|
268
|
+
username: 'user',
|
269
|
+
host: 'abc123.database.windows.net',
|
270
|
+
azure: false
|
271
|
+
)
|
223
272
|
).must_equal 'user'
|
224
273
|
end
|
225
|
-
|
226
274
|
end
|
227
|
-
|
228
|
-
|
229
275
|
end
|
230
|
-
|
data/test/gem_test.rb
CHANGED
@@ -9,11 +9,11 @@ class GemTest < MiniTest::Spec
|
|
9
9
|
|
10
10
|
# We're going to muck with some system globals so lets make sure
|
11
11
|
# they get set back later
|
12
|
-
|
12
|
+
original_platform = RbConfig::CONFIG['arch']
|
13
13
|
original_pwd = Dir.pwd
|
14
14
|
|
15
15
|
after do
|
16
|
-
RbConfig::CONFIG['
|
16
|
+
RbConfig::CONFIG['arch'] = original_platform
|
17
17
|
Dir.chdir original_pwd
|
18
18
|
end
|
19
19
|
|
@@ -21,13 +21,13 @@ class GemTest < MiniTest::Spec
|
|
21
21
|
let(:root_path) { TinyTds::Gem.root_path }
|
22
22
|
|
23
23
|
it 'should be the root path' do
|
24
|
-
root_path.must_equal gem_root
|
24
|
+
_(root_path).must_equal gem_root
|
25
25
|
end
|
26
26
|
|
27
27
|
it 'should be the root path no matter the cwd' do
|
28
28
|
Dir.chdir '/'
|
29
29
|
|
30
|
-
root_path.must_equal gem_root
|
30
|
+
_(root_path).must_equal gem_root
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
@@ -35,19 +35,19 @@ class GemTest < MiniTest::Spec
|
|
35
35
|
let(:ports_root_path) { TinyTds::Gem.ports_root_path }
|
36
36
|
|
37
37
|
it 'should be the ports path' do
|
38
|
-
ports_root_path.must_equal File.join(gem_root,'ports')
|
38
|
+
_(ports_root_path).must_equal File.join(gem_root,'ports')
|
39
39
|
end
|
40
40
|
|
41
41
|
it 'should be the ports path no matter the cwd' do
|
42
42
|
Dir.chdir '/'
|
43
43
|
|
44
|
-
ports_root_path.must_equal File.join(gem_root,'ports')
|
44
|
+
_(ports_root_path).must_equal File.join(gem_root,'ports')
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
48
48
|
describe '#ports_bin_paths' do
|
49
49
|
let(:ports_bin_paths) { TinyTds::Gem.ports_bin_paths }
|
50
|
-
|
50
|
+
|
51
51
|
describe 'when the ports directories exist' do
|
52
52
|
let(:fake_bin_paths) do
|
53
53
|
ports_host_root = File.join(gem_root, 'ports', 'fake-host-with-dirs')
|
@@ -61,7 +61,7 @@ class GemTest < MiniTest::Spec
|
|
61
61
|
end
|
62
62
|
|
63
63
|
before do
|
64
|
-
RbConfig::CONFIG['
|
64
|
+
RbConfig::CONFIG['arch'] = 'fake-host-with-dirs'
|
65
65
|
fake_bin_paths.each do |path|
|
66
66
|
FileUtils.mkdir_p(path)
|
67
67
|
end
|
@@ -74,34 +74,34 @@ class GemTest < MiniTest::Spec
|
|
74
74
|
end
|
75
75
|
|
76
76
|
it 'should return all the bin directories' do
|
77
|
-
ports_bin_paths.sort.must_equal fake_bin_paths.sort
|
77
|
+
_(ports_bin_paths.sort).must_equal fake_bin_paths.sort
|
78
78
|
end
|
79
79
|
|
80
80
|
it 'should return all the bin directories regardless of cwd' do
|
81
81
|
Dir.chdir '/'
|
82
|
-
ports_bin_paths.sort.must_equal fake_bin_paths.sort
|
82
|
+
_(ports_bin_paths.sort).must_equal fake_bin_paths.sort
|
83
83
|
end
|
84
84
|
end
|
85
85
|
|
86
86
|
describe 'when the ports directories are missing' do
|
87
87
|
before do
|
88
|
-
RbConfig::CONFIG['
|
88
|
+
RbConfig::CONFIG['arch'] = 'fake-host-without-dirs'
|
89
89
|
end
|
90
90
|
|
91
91
|
it 'should return no directories' do
|
92
|
-
ports_bin_paths.must_be_empty
|
92
|
+
_(ports_bin_paths).must_be_empty
|
93
93
|
end
|
94
94
|
|
95
95
|
it 'should return no directories regardless of cwd' do
|
96
96
|
Dir.chdir '/'
|
97
|
-
ports_bin_paths.must_be_empty
|
97
|
+
_(ports_bin_paths).must_be_empty
|
98
98
|
end
|
99
99
|
end
|
100
100
|
end
|
101
101
|
|
102
102
|
describe '#ports_lib_paths' do
|
103
103
|
let(:ports_lib_paths) { TinyTds::Gem.ports_lib_paths }
|
104
|
-
|
104
|
+
|
105
105
|
describe 'when the ports directories exist' do
|
106
106
|
let(:fake_lib_paths) do
|
107
107
|
ports_host_root = File.join(gem_root, 'ports', 'fake-host-with-dirs')
|
@@ -115,7 +115,7 @@ class GemTest < MiniTest::Spec
|
|
115
115
|
end
|
116
116
|
|
117
117
|
before do
|
118
|
-
RbConfig::CONFIG['
|
118
|
+
RbConfig::CONFIG['arch'] = 'fake-host-with-dirs'
|
119
119
|
fake_lib_paths.each do |path|
|
120
120
|
FileUtils.mkdir_p(path)
|
121
121
|
end
|
@@ -128,48 +128,46 @@ class GemTest < MiniTest::Spec
|
|
128
128
|
end
|
129
129
|
|
130
130
|
it 'should return all the lib directories' do
|
131
|
-
ports_lib_paths.sort.must_equal fake_lib_paths.sort
|
131
|
+
_(ports_lib_paths.sort).must_equal fake_lib_paths.sort
|
132
132
|
end
|
133
133
|
|
134
134
|
it 'should return all the lib directories regardless of cwd' do
|
135
135
|
Dir.chdir '/'
|
136
|
-
ports_lib_paths.sort.must_equal fake_lib_paths.sort
|
136
|
+
_(ports_lib_paths.sort).must_equal fake_lib_paths.sort
|
137
137
|
end
|
138
138
|
end
|
139
139
|
|
140
140
|
describe 'when the ports directories are missing' do
|
141
141
|
before do
|
142
|
-
RbConfig::CONFIG['
|
142
|
+
RbConfig::CONFIG['arch'] = 'fake-host-without-dirs'
|
143
143
|
end
|
144
144
|
|
145
145
|
|
146
146
|
it 'should return no directories' do
|
147
|
-
ports_lib_paths.must_be_empty
|
147
|
+
_(ports_lib_paths).must_be_empty
|
148
148
|
end
|
149
149
|
|
150
150
|
it 'should return no directories regardless of cwd' do
|
151
151
|
Dir.chdir '/'
|
152
|
-
ports_lib_paths.must_be_empty
|
152
|
+
_(ports_lib_paths).must_be_empty
|
153
153
|
end
|
154
154
|
end
|
155
155
|
end
|
156
156
|
|
157
157
|
describe '#ports_host' do
|
158
158
|
{
|
159
|
-
'
|
160
|
-
'
|
161
|
-
'
|
162
|
-
'x86_64-
|
163
|
-
# consolidate this host to our build w64-mingw32 arch
|
164
|
-
'i686-pc-mingw32' => 'i686-w64-mingw32'
|
159
|
+
'x64-mingw-ucrt' => 'x64-mingw-ucrt',
|
160
|
+
'x64-mingw32' => 'x64-mingw32',
|
161
|
+
'x86-mingw32' => 'x86-mingw32',
|
162
|
+
'x86_64-linux' => 'x86_64-linux',
|
165
163
|
}.each do |host,expected|
|
166
164
|
describe "on a #{host} architecture" do
|
167
165
|
before do
|
168
|
-
RbConfig::CONFIG['
|
166
|
+
RbConfig::CONFIG['arch'] = host
|
169
167
|
end
|
170
168
|
|
171
169
|
it "should return a #{expected} ports host" do
|
172
|
-
TinyTds::Gem.ports_host.must_equal expected
|
170
|
+
_(TinyTds::Gem.ports_host).must_equal expected
|
173
171
|
end
|
174
172
|
end
|
175
173
|
end
|