Skip to content

Commit 3df9532

Browse files
committed
Increase test coverage
1 parent 0f236ab commit 3df9532

File tree

2 files changed

+11
-21
lines changed

2 files changed

+11
-21
lines changed

tds.go

-5
Original file line numberDiff line numberDiff line change
@@ -994,7 +994,6 @@ initiate_connection:
994994
}
995995

996996
// processing login response
997-
success := false
998997
for {
999998
tokchan := make(chan tokenStruct, 5)
1000999
go processResponse(context.Background(), &sess, tokchan, nil)
@@ -1018,7 +1017,6 @@ initiate_connection:
10181017
sspi_msg = nil
10191018
}
10201019
case loginAckStruct:
1021-
success = true
10221020
sess.loginAck = token
10231021
case error:
10241022
return nil, fmt.Errorf("Login error: %s", token.Error())
@@ -1036,9 +1034,6 @@ initiate_connection:
10361034
}
10371035
}
10381036
loginEnd:
1039-
if !success {
1040-
return nil, fmt.Errorf("Login failed")
1041-
}
10421037
if sess.routedServer != "" {
10431038
toconn.Close()
10441039
p.host = sess.routedServer

tds_test.go

+11-16
Original file line numberDiff line numberDiff line change
@@ -415,23 +415,18 @@ func TestSecureConnection(t *testing.T) {
415415
}
416416
}
417417

418-
func TestBadConnect(t *testing.T) {
419-
checkConnStr(t)
420-
SetLogger(testLogger{t})
421-
connURL := makeConnStr(t)
422-
connURL.User = url.UserPassword("baduser", "badpwd")
423-
badDSN := connURL.String()
424-
425-
conn, err := sql.Open("mssql", badDSN)
426-
if err != nil {
427-
t.Error("Open connection failed:", err.Error())
428-
}
429-
defer conn.Close()
418+
func TestBadCredentials(t *testing.T) {
419+
params := testConnParams(t)
420+
params.password = "padpwd"
421+
params.user = "baduser"
422+
testConnectionBad(t, params.toUrl().String())
423+
}
430424

431-
err = conn.Ping()
432-
if err == nil {
433-
t.Error("Ping should fail for connection: ", badDSN)
434-
}
425+
func TestBadHost(t *testing.T) {
426+
params := testConnParams(t)
427+
params.host = "badhost"
428+
params.instance = ""
429+
testConnectionBad(t, params.toUrl().String())
435430
}
436431

437432
func TestSSPIAuth(t *testing.T) {

0 commit comments

Comments
 (0)