summaryrefslogtreecommitdiff
path: root/internal/configuration/validator/storage_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/configuration/validator/storage_test.go')
-rw-r--r--internal/configuration/validator/storage_test.go39
1 files changed, 39 insertions, 0 deletions
diff --git a/internal/configuration/validator/storage_test.go b/internal/configuration/validator/storage_test.go
index 29f9d42c4..fae3ab681 100644
--- a/internal/configuration/validator/storage_test.go
+++ b/internal/configuration/validator/storage_test.go
@@ -116,6 +116,24 @@ func (suite *StorageSuite) TestShouldSetDefaultMySQLTLSServerName() {
suite.Assert().Equal("mysql", suite.config.MySQL.TLS.ServerName)
}
+func (suite *StorageSuite) TestShouldRaiseErrorOnInvalidMySQLAddressScheme() {
+ suite.config.MySQL = &schema.StorageMySQL{
+ StorageSQL: schema.StorageSQL{
+ Address: &schema.AddressTCP{Address: MustParseAddress("udp://mysql:1234")},
+ Username: "myuser",
+ Password: "pass",
+ Database: "database",
+ },
+ }
+
+ ValidateStorage(suite.config, suite.val)
+
+ suite.Len(suite.val.Warnings(), 0)
+ suite.Require().Len(suite.val.Errors(), 1)
+
+ suite.EqualError(suite.val.Errors()[0], "server: option 'address' with value 'udp://mysql:1234' is invalid: scheme must be one of 'tcp', 'tcp4', 'tcp6', or 'unix' but is configured as 'udp'")
+}
+
func (suite *StorageSuite) TestShouldRaiseErrorOnInvalidMySQLTLSVersion() {
suite.config.MySQL = &schema.StorageMySQL{
StorageSQL: schema.StorageSQL{
@@ -213,6 +231,27 @@ func (suite *StorageSuite) TestShouldValidatePostgresSchemaDefault() {
suite.Assert().Equal("public", suite.config.PostgreSQL.Schema)
}
+func (suite *StorageSuite) TestShouldValidatePostgresPortDefault() {
+ suite.config.PostgreSQL = &schema.StoragePostgreSQL{
+ StorageSQL: schema.StorageSQL{
+ Address: &schema.AddressTCP{
+ Address: MustParseAddress("tcp://postgre"),
+ },
+ Username: "myuser",
+ Password: "pass",
+ Database: "database",
+ },
+ Schema: "public",
+ }
+
+ ValidateStorage(suite.config, suite.val)
+
+ suite.Assert().Len(suite.val.Warnings(), 0)
+ suite.Assert().Len(suite.val.Errors(), 0)
+
+ suite.Equal(uint16(5432), suite.config.PostgreSQL.Address.Port())
+}
+
func (suite *StorageSuite) TestShouldValidatePostgresTLSDefaults() {
suite.config.PostgreSQL = &schema.StoragePostgreSQL{
StorageSQL: schema.StorageSQL{