@@ -8,6 +8,7 @@ import org.scalatest.funsuite.AnyFunSuite
88
99class DatabricksConfigParserSuite extends AnyFunSuite {
1010 private val testHost = " defaulthost"
11+ private val trailingSlashRemovedHost = " https://anotherhost.com"
1112 private val testToken = " defaulttoken"
1213
1314 test(" PROFILE - Successfully gets host/token from profile" ) {
@@ -46,6 +47,20 @@ class DatabricksConfigParserSuite extends AnyFunSuite {
4647 stream.close()
4748 }
4849
50+ test(" PROFILE - Successfully remove host trailing slash from profile" ) {
51+ val profileName = " TRAILING_SLASH"
52+ val stream = new java.io.ByteArrayOutputStream ()
53+ val env =
54+ Map (configFilePathEnvVariable -> getClass.getResource(" .testcfg" ).getPath)
55+ val (host, token) = Console .withErr(stream) {
56+ getHostAndToken(useEnvVariables = false , profileName, env)
57+ }
58+ assert(stream.toString.isEmpty)
59+ assert(host.get == trailingSlashRemovedHost)
60+ assert(token.get == testToken)
61+ stream.close()
62+ }
63+
4964 test(
5065 " ENVIRONMENT VARIABLES - Successfully gets host/token from env variables"
5166 ) {
@@ -87,4 +102,16 @@ class DatabricksConfigParserSuite extends AnyFunSuite {
87102 )
88103 stream.close()
89104 }
105+
106+ test(" ENVIRONMENT VARIABLES - Successfully remove host trailing slash" ) {
107+ val env = Map (hostEnvVariable -> s " $trailingSlashRemovedHost/ " , tokenEnvVariable -> testToken)
108+ val stream = new java.io.ByteArrayOutputStream ()
109+ val (host, token) = Console .withOut(stream) {
110+ getHostAndToken(useEnvVariables = true , " default" , env)
111+ }
112+ assert(stream.toString.isEmpty)
113+ assert(host.get == trailingSlashRemovedHost)
114+ assert(token.get == testToken)
115+ stream.close()
116+ }
90117}
0 commit comments