-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathConfigSpec.scala
More file actions
84 lines (81 loc) · 3.72 KB
/
Copy pathConfigSpec.scala
File metadata and controls
84 lines (81 loc) · 3.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
package scalikejdbc.athena
import org.scalatest.OptionValues
import org.scalatest.funspec.AnyFunSpec
class ConfigSpec extends AnyFunSpec with OptionValues {
describe("Config") {
it("default db") {
val config = new Config("default")
assert(config.url === "jdbc:athena://AwsRegion=us-east-2")
assert(config.options.getProperty("S3OutputLocation") === "s3://query-results-bucket/folder/")
assert(config.options.getProperty("LogPath") === "logs/application.log")
assert(config.getTmpStagingDir.isEmpty)
assert(config.readOnly.value === false)
assert(config.timeZone.isEmpty)
assert(config.useCustomPreparedStatement === false)
}
it("workgropup") {
val config = new Config("workgroup-only")
assert(config.url === "jdbc:athena://AwsRegion=us-east-2")
assert(config.options.getProperty("S3OutputLocation") === null)
assert(config.options.getProperty("WorkGroup") === "my-own-workgroup")
assert(config.options.getProperty("LogPath") === "logs/application.log")
assert(config.getTmpStagingDir.isEmpty)
assert(config.readOnly.value === false)
assert(config.timeZone.isEmpty)
assert(config.useCustomPreparedStatement === false)
}
it("primary workgroupRequires S3OutputLocation") {
assertThrows[ConfigException](new Config("workgroup-primary").options)
}
it("named db") {
val config = new Config("athena")
assert(config.url === "jdbc:athena://AwsRegion=ap-southeast-1")
assert(config.options.getProperty("S3OutputLocation") !== "s3://query-results-bucket/folder")
assert(config.options.getProperty("S3OutputLocation").startsWith("s3://query-results-bucket/folder") === true)
assert(config.options.containsKey("LogPath") === false)
assert(config.getTmpStagingDir.value === config.options.getProperty("S3OutputLocation"))
assert(config.readOnly.value === true)
assert(config.timeZone.value === "UTC")
assert(config.useCustomPreparedStatement === false)
}
it("v3") {
// This test ensures that new config parameters is supported
val config = new Config("v3params")
assert(config.url === "jdbc:athena://AwsRegion=ap-southeast-1")
assert(config.options.getProperty("DataZoneEnvironmentId") === "123")
assert(config.options.getProperty("DataZoneDomainRegion") === "us-west-2")
}
it("v2") {
val config = new Config("v2.default")
assert(config.url === "jdbc:awsathena://AwsRegion=us-east-2")
assert(config.options.getProperty("S3OutputLocation") === null)
assert(config.options.getProperty("Workgroup") === "my-own-workgroup")
assert(config.options.getProperty("LogPath") === "logs/application.log")
assert(config.getTmpStagingDir.isEmpty)
assert(config.readOnly.value === false)
assert(config.timeZone.isEmpty)
assert(config.useCustomPreparedStatement === false)
}
it("invalid settings") {
val config = new Config("duplicated")
assertThrows[ConfigException](config.options)
assert(config.readOnly.isEmpty)
}
it("unconfigured db") {
assertThrows[ConfigException](new Config("unconfigured"))
}
it("unsupported db name type") {
assertThrows[ConfigException](new Config("athena".toCharArray))
}
it("compat") {
val config = new Config("compat")
assert(config.url === "jdbc:athena://AwsRegion=ap-southeast-1")
assert(config.options.getProperty("S3OutputLocation") === "s3://query-results-bucket/folder/")
assert(config.options.getProperty("LogPath") === null)
assert(config.getTmpStagingDir.isEmpty)
assert(config.readOnly.isEmpty)
assert(config.timeZone.isEmpty)
assert(config.useCustomPreparedStatement === true)
}
}
}