Skip to content

Commit

Permalink
Increase test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
denisenkom committed Nov 5, 2020
1 parent 0f236ab commit 3df9532
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 21 deletions.
5 changes: 0 additions & 5 deletions tds.go
Original file line number Diff line number Diff line change
Expand Up @@ -994,7 +994,6 @@ initiate_connection:
}

// processing login response
success := false
for {
tokchan := make(chan tokenStruct, 5)
go processResponse(context.Background(), &sess, tokchan, nil)
Expand All @@ -1018,7 +1017,6 @@ initiate_connection:
sspi_msg = nil
}
case loginAckStruct:
success = true
sess.loginAck = token
case error:
return nil, fmt.Errorf("Login error: %s", token.Error())
Expand All @@ -1036,9 +1034,6 @@ initiate_connection:
}
}
loginEnd:
if !success {
return nil, fmt.Errorf("Login failed")
}
if sess.routedServer != "" {
toconn.Close()
p.host = sess.routedServer
Expand Down
27 changes: 11 additions & 16 deletions tds_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -415,23 +415,18 @@ func TestSecureConnection(t *testing.T) {
}
}

func TestBadConnect(t *testing.T) {
checkConnStr(t)
SetLogger(testLogger{t})
connURL := makeConnStr(t)
connURL.User = url.UserPassword("baduser", "badpwd")
badDSN := connURL.String()

conn, err := sql.Open("mssql", badDSN)
if err != nil {
t.Error("Open connection failed:", err.Error())
}
defer conn.Close()
func TestBadCredentials(t *testing.T) {
params := testConnParams(t)
params.password = "padpwd"
params.user = "baduser"
testConnectionBad(t, params.toUrl().String())
}

err = conn.Ping()
if err == nil {
t.Error("Ping should fail for connection: ", badDSN)
}
func TestBadHost(t *testing.T) {
params := testConnParams(t)
params.host = "badhost"
params.instance = ""
testConnectionBad(t, params.toUrl().String())
}

func TestSSPIAuth(t *testing.T) {
Expand Down

0 comments on commit 3df9532

Please sign in to comment.