Skip to content

Commit fe62754

Browse files
bottleneckedmjaric
authored andcommitted
account for windows shell newline when running sqlcmd (#78)
1 parent 45b0ba9 commit fe62754

File tree

1 file changed

+25
-20
lines changed

1 file changed

+25
-20
lines changed

test/test_helper.exs

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -63,35 +63,40 @@ end
6363

6464
opts = Application.get_env(:tds, :opts)
6565
database = opts[:database]
66-
{"", 0} = Tds.TestHelper.sqlcmd(opts, """
67-
IF EXISTS(SELECT * FROM sys.databases where name = '#{database}')
68-
BEGIN
69-
DROP DATABASE [#{database}];
70-
END;
71-
CREATE DATABASE [#{database}];
72-
""")
73-
{"Changed database context to 'test'.\n", 0} = Tds.TestHelper.sqlcmd(opts, """
74-
USE [test];
7566

76-
CREATE TABLE altering ([a] int)
67+
{"", 0} =
68+
Tds.TestHelper.sqlcmd(opts, """
69+
IF EXISTS(SELECT * FROM sys.databases where name = '#{database}')
70+
BEGIN
71+
DROP DATABASE [#{database}];
72+
END;
73+
CREATE DATABASE [#{database}];
74+
""")
7775

78-
CREATE TABLE [composite1] ([a] int, [b] text);
79-
CREATE TABLE [composite2] ([a] int, [b] int, [c] int);
80-
CREATE TABLE [uniques] ([id] int NOT NULL, CONSTRAINT UIX_uniques_id UNIQUE([id]))
81-
""")
76+
{"Changed database context to 'test'." <> _newline, 0} =
77+
Tds.TestHelper.sqlcmd(opts, """
78+
USE [test];
79+
80+
CREATE TABLE altering ([a] int)
81+
82+
CREATE TABLE [composite1] ([a] int, [b] text);
83+
CREATE TABLE [composite2] ([a] int, [b] int, [c] int);
84+
CREATE TABLE [uniques] ([id] int NOT NULL, CONSTRAINT UIX_uniques_id UNIQUE([id]))
85+
""")
86+
87+
{"Changed database context to 'test'." <> _newline, 0} =
88+
Tds.TestHelper.sqlcmd(opts, """
89+
USE test
90+
GO
91+
CREATE SCHEMA test;
92+
""")
8293

83-
{"Changed database context to 'test'.\n", 0} = Tds.TestHelper.sqlcmd opts, """
84-
USE test
85-
GO
86-
CREATE SCHEMA test;
87-
"""
8894
# :dbg.start()
8995
# :dbg.tracer()
9096
# :dbg.p(:all, :c)
9197
# :dbg.tpl(:gen_tcp, :_, [])
9298
# :dbg.tpl(Tds.Protocol, :_, [])
9399
# :dbg.tpl(DBConnection, :_, :x)
94100

95-
96101
ExUnit.start()
97102
ExUnit.configure(exclude: [:manual])

0 commit comments

Comments
 (0)