Skip to content

Commit

Permalink
*nix support for development
Browse files Browse the repository at this point in the history
  • Loading branch information
mjaric committed Nov 23, 2017
1 parent 0d9bed1 commit c2b180f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ $ mix test
```

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/)

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)

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

Expand Down
2 changes: 1 addition & 1 deletion config/test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ config :logger, level: :info

config :tds,
opts: [
hostname: "localhost",
hostname: "127.0.0.1",
username: "sa",
password: "some!Password",
database: "test"
Expand Down
16 changes: 16 additions & 0 deletions test/test_helper.exs
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,20 @@ defmodule Tds.TestHelper do
end
end
end

def sqlcmd(params, sql, args \\ []) do
args = [
"-U", params[:username],
"-P", params[:password],
"-S", params[:hostname],
"-Q", ~s(#{sql}) | args]
|> IO.inspect()
System.cmd "sqlcmd", args
end
end


Application.get_env(:tds, :opts)

|> IO.inspect()
|> Tds.TestHelper.sqlcmd "IF NOT EXISTS(SELECT * FROM sys.databases where name = 'test') BEGIN CREATE DATABASE [test]; END;"

0 comments on commit c2b180f

Please sign in to comment.