Skip to content

Commit c2b180f

Browse files
committed
*nix support for development
1 parent 0d9bed1 commit c2b180f

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ $ mix test
6666
```
6767

6868
The tests require your sql server database to be present on localhost. In case you are unable to run local instance of SQL server either using local installation on [windows](https://docs.microsoft.com/en-us/sql/database-engine/install-windows/install-sql-server-from-the-installation-wizard-setup) or [linix](https://docs.microsoft.com/en-us/sql/linux/sql-server-linux-setup), docker image for [linux](https://hub.docker.com/r/microsoft/mssql-server-linux/)
69-
69+
You will need sqlcmd command line tools for some operations in test. Setup instructions can be found [here](https://docs.microsoft.com/en-us/sql/linux/sql-server-linux-setup-tools)
7070

7171
Additionally SQL authentication needs to be used for connecting and testing. Check config/test.exs file for credentials used in unit testing.
7272

config/test.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ config :logger, level: :info
44

55
config :tds,
66
opts: [
7-
hostname: "localhost",
7+
hostname: "127.0.0.1",
88
username: "sa",
99
password: "some!Password",
1010
database: "test"

test/test_helper.exs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,20 @@ defmodule Tds.TestHelper do
2525
end
2626
end
2727
end
28+
29+
def sqlcmd(params, sql, args \\ []) do
30+
args = [
31+
"-U", params[:username],
32+
"-P", params[:password],
33+
"-S", params[:hostname],
34+
"-Q", ~s(#{sql}) | args]
35+
|> IO.inspect()
36+
System.cmd "sqlcmd", args
37+
end
2838
end
39+
40+
41+
Application.get_env(:tds, :opts)
42+
43+
|> IO.inspect()
44+
|> Tds.TestHelper.sqlcmd "IF NOT EXISTS(SELECT * FROM sys.databases where name = 'test') BEGIN CREATE DATABASE [test]; END;"

0 commit comments

Comments
 (0)