Skip to content

Commit f0e0ce9

Browse files
committed
add test coverage for nullable fields
1 parent 14ab831 commit f0e0ce9

File tree

2 files changed

+68
-0
lines changed

2 files changed

+68
-0
lines changed

test/integration/models/database/helpers.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,14 @@ def make_full_mysql_engine_config():
6565
)
6666

6767

68+
def make_mysql_engine_config_w_nullable_field():
69+
return MySQLDatabaseConfigOptions(
70+
mysql=MySQLDatabaseConfigMySQLOptions(
71+
innodb_ft_server_stopword_table=None,
72+
),
73+
)
74+
75+
6876
def make_full_postgres_engine_config():
6977
return PostgreSQLDatabaseConfigOptions(
7078
pg=PostgreSQLDatabaseConfigPGOptions(
@@ -114,3 +122,11 @@ def make_full_postgres_engine_config():
114122
shared_buffers_percentage=25.0,
115123
work_mem=1024,
116124
)
125+
126+
127+
def make_postgres_engine_config_w_password_encryption_null():
128+
return PostgreSQLDatabaseConfigOptions(
129+
pg=PostgreSQLDatabaseConfigPGOptions(
130+
password_encryption=None,
131+
),
132+
)

test/integration/models/database/test_database_engine_config.py

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
get_sql_db_status,
1111
make_full_mysql_engine_config,
1212
make_full_postgres_engine_config,
13+
make_mysql_engine_config_w_nullable_field,
14+
make_postgres_engine_config_w_password_encryption_null,
1315
)
1416

1517
import pytest
@@ -221,6 +223,31 @@ def test_get_mysql_engine_config(
221223
assert isinstance(db, MySQLDatabase)
222224

223225

226+
@pytest.mark.skipif(
227+
os.getenv("RUN_DB_TESTS", "").strip().lower() not in {"yes", "true"},
228+
reason="RUN_DB_TESTS environment variable must be set to 'yes' or 'true' (case insensitive)",
229+
)
230+
def test_create_mysql_db_nullable_field(test_linode_client):
231+
client = test_linode_client
232+
label = get_test_label(5) + "-sqldb"
233+
region = "us-ord"
234+
engine_id = get_db_engine_id(client, "mysql")
235+
dbtype = "g6-standard-1"
236+
237+
db = client.database.mysql_create(
238+
label=label,
239+
region=region,
240+
engine=engine_id,
241+
ltype=dbtype,
242+
cluster_size=None,
243+
engine_config=make_mysql_engine_config_w_nullable_field(),
244+
)
245+
246+
assert db.engine_config.mysql.innodb_ft_server_stopword_table is None
247+
248+
send_request_when_resource_available(300, db.delete)
249+
250+
224251
# POSTGRESQL
225252
@pytest.mark.skipif(
226253
os.getenv("RUN_DB_TESTS", "").strip().lower() not in {"yes", "true"},
@@ -421,3 +448,28 @@ def test_get_postgres_engine_config(
421448
)
422449

423450
assert isinstance(db, PostgreSQLDatabase)
451+
452+
453+
@pytest.mark.skipif(
454+
os.getenv("RUN_DB_TESTS", "").strip().lower() not in {"yes", "true"},
455+
reason="RUN_DB_TESTS environment variable must be set to 'yes' or 'true' (case insensitive)",
456+
)
457+
def test_create_postgres_db_password_encryption_default_md5(test_linode_client):
458+
client = test_linode_client
459+
label = get_test_label() + "-postgresqldb"
460+
region = "us-ord"
461+
engine_id = "postgresql/17"
462+
dbtype = "g6-standard-1"
463+
464+
db = client.database.postgresql_create(
465+
label=label,
466+
region=region,
467+
engine=engine_id,
468+
ltype=dbtype,
469+
cluster_size=None,
470+
engine_config=make_postgres_engine_config_w_password_encryption_null(),
471+
)
472+
473+
assert db.engine_config.pg.password_encryption == "md5"
474+
475+
send_request_when_resource_available(300, db.delete)

0 commit comments

Comments
 (0)