summaryrefslogtreecommitdiff
path: root/internal/configuration/validator/storage_test.go
diff options
context:
space:
mode:
authorJames Elliott <james-d-elliott@users.noreply.github.com>2025-02-18 20:38:36 +1100
committerGitHub <noreply@github.com>2025-02-18 09:38:36 +0000
commita9d1986fa9dec8701ee73b05aa99781f4bbe5f18 (patch)
treebbcef1a55483271f43308179d4fd09ef8a894131 /internal/configuration/validator/storage_test.go
parent7ac3c6a4f3945c3c4272bac717addd1ef598b2b9 (diff)
feat(configuration): reusable definitions (#8077)
This adds reusable definitions into the mix for the configuration. This replaces the existing networks section for the access_control section and is automatically remapped for users. Signed-off-by: James Elliott <james-d-elliott@users.noreply.github.com>
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{