Skip to content

Commit 8859688

Browse files
jcrossleyjenkins
authored and
jenkins
committed
finagle/finagle-mysql: Move HandshakeSettingsTest into Bazel target and fix tests
Problem The HandshakeSettingsTest was outside of the mysql testing targets, so it didn't run as part of Bazel testing. This lead to a failing test being committed. Solution Fix the test and move it into the `unit` target. Differential Revision: https://phabricator.twitter.biz/D1140246
1 parent d1468ba commit 8859688

File tree

1 file changed

+13
-20
lines changed

1 file changed

+13
-20
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
package com.twitter.finagle.mysql
1+
package com.twitter.finagle.mysql.unit
22

33
import com.twitter.finagle.Stack
4+
import com.twitter.finagle.mysql.Capability
5+
import com.twitter.finagle.mysql.HandshakeSettings
6+
import com.twitter.finagle.mysql.MysqlCharset
47
import com.twitter.finagle.mysql.param.Charset
58
import com.twitter.finagle.mysql.param.Credentials
69
import com.twitter.finagle.mysql.param.Database
@@ -14,40 +17,31 @@ class HandshakeSettingsTest extends AnyFunSuite {
1417
Capability.Transactions,
1518
Capability.MultiResults
1619
)
17-
private val withFoundRows = initial + Capability.FoundRows
18-
private val withInteractive = initial + Capability.Interactive
1920

2021
test("HandshakeSettings adds FoundRows by default") {
2122
val settings = HandshakeSettings(clientCapabilities = initial)
22-
assert(settings.calculatedClientCapabilities == withFoundRows)
23+
assert(settings.calculatedClientCapabilities.has(Capability.FoundRows))
2324
}
2425

25-
test("HandshakeSettings returns initial when found rows is disabled") {
26+
test("HandshakeSettings does not add FoundRows when found rows is disabled") {
2627
val settings = HandshakeSettings(clientCapabilities = initial, enableFoundRows = false)
27-
assert(settings.calculatedClientCapabilities == initial)
28+
assert(!settings.calculatedClientCapabilities.has(Capability.FoundRows))
2829
}
2930

3031
test("HandshakeSettings adds Interactive by default") {
3132
val settings = HandshakeSettings(clientCapabilities = initial)
32-
assert(settings.calculatedClientCapabilities == withInteractive)
33+
assert(settings.calculatedClientCapabilities.has(Capability.Interactive))
3334
}
3435

35-
test("HandshakeSettings returns initial when interactive is disabled") {
36+
test("HandshakeSettings does not add Interactive when interactive is disabled") {
3637
val settings = HandshakeSettings(clientCapabilities = initial, interactive = false)
37-
assert(settings.calculatedClientCapabilities == initial)
38+
assert(!settings.calculatedClientCapabilities.has(Capability.Interactive))
3839
}
3940

40-
test("HandshakeSettings adds ConnectWithDB if database is defined") {
41+
test("HandshakeSettings adds ConnectWithDB and SSL settings if database is defined") {
4142
val settings = HandshakeSettings(clientCapabilities = initial, database = Some("test"))
42-
val withDB = withFoundRows + Capability.ConnectWithDB
43-
assert(settings.calculatedClientCapabilities == withDB)
44-
}
45-
46-
test("HandshakeSettings can calculate settings for SSL/TLS") {
47-
val settings = HandshakeSettings(clientCapabilities = initial, database = Some("test"))
48-
val withDB = withFoundRows + Capability.ConnectWithDB
49-
val withSSL = withDB + Capability.SSL
50-
assert(settings.sslCalculatedClientCapabilities == withSSL)
43+
assert(settings.calculatedClientCapabilities.has(Capability.ConnectWithDB))
44+
assert(settings.sslCalculatedClientCapabilities.has(Capability.SSL))
5145
}
5246

5347
test("HandshakeSettings can read values from Stack params") {
@@ -65,5 +59,4 @@ class HandshakeSettingsTest extends AnyFunSuite {
6559
assert(!settings.enableFoundRows)
6660
assert(!settings.interactive)
6761
}
68-
6962
}

0 commit comments

Comments
 (0)