From 189a0cee468c23931980c26be4bad817a424ccb6 Mon Sep 17 00:00:00 2001 From: Marco Craveiro Date: Sun, 1 Feb 2026 23:28:28 +0000 Subject: [PATCH 1/3] Use PGPASSWORD env var for postgres test credentials Add test_helpers.hpp with make_credentials() that checks for PGPASSWORD environment variable, falling back to "password" if not set. This allows running tests against an existing postgres instance. Co-Authored-By: Claude Opus 4.5 --- tests/postgres/test_aggregations.cpp | 6 ++--- .../test_aggregations_with_nullable.cpp | 6 ++--- tests/postgres/test_auto_incr_primary_key.cpp | 6 ++--- tests/postgres/test_boolean.cpp | 6 ++--- tests/postgres/test_boolean_conditions.cpp | 6 ++--- tests/postgres/test_boolean_update.cpp | 6 ++--- tests/postgres/test_cache.cpp | 6 ++--- tests/postgres/test_create_index.cpp | 6 ++--- tests/postgres/test_create_index_where.cpp | 6 ++--- tests/postgres/test_create_table.cpp | 6 ++--- tests/postgres/test_create_table_as.cpp | 6 ++--- tests/postgres/test_create_view_as.cpp | 6 ++--- tests/postgres/test_delete_from.cpp | 6 ++--- tests/postgres/test_dynamic_type.cpp | 6 ++--- tests/postgres/test_enum_crosstable.cpp | 6 ++--- tests/postgres/test_enum_lookup.cpp | 6 ++--- tests/postgres/test_enum_namespace.cpp | 6 ++--- tests/postgres/test_error_handling.cpp | 6 ++--- tests/postgres/test_foreign_key.cpp | 6 ++--- tests/postgres/test_full_join.cpp | 6 ++--- tests/postgres/test_group_by.cpp | 6 ++--- .../test_group_by_with_operations.cpp | 6 ++--- tests/postgres/test_helpers.hpp | 19 ++++++++++++++ tests/postgres/test_in.cpp | 6 ++--- tests/postgres/test_in_vec.cpp | 6 ++--- tests/postgres/test_insert_and_read.cpp | 6 ++--- .../test_insert_and_read_two_tables.cpp | 6 ++--- tests/postgres/test_insert_fail.cpp | 6 ++--- tests/postgres/test_insert_or_replace.cpp | 6 ++--- tests/postgres/test_is_null.cpp | 6 ++--- tests/postgres/test_join.cpp | 6 ++--- tests/postgres/test_joins_from.cpp | 6 ++--- tests/postgres/test_joins_nested.cpp | 6 ++--- tests/postgres/test_joins_nested_grouped.cpp | 6 ++--- tests/postgres/test_joins_two_tables.cpp | 6 ++--- .../test_joins_two_tables_grouped.cpp | 6 ++--- tests/postgres/test_json.cpp | 6 ++--- tests/postgres/test_left_join.cpp | 6 ++--- tests/postgres/test_like.cpp | 6 ++--- tests/postgres/test_limit.cpp | 6 ++--- tests/postgres/test_listen_notify.cpp | 26 +++++-------------- tests/postgres/test_not_in.cpp | 6 ++--- tests/postgres/test_not_in_vec.cpp | 6 ++--- tests/postgres/test_offset.cpp | 6 ++--- tests/postgres/test_operations.cpp | 6 ++--- .../test_operations_with_nullable.cpp | 6 ++--- tests/postgres/test_range.cpp | 6 ++--- tests/postgres/test_range_select_from.cpp | 6 ++--- tests/postgres/test_right_join.cpp | 6 ++--- .../test_select_from_with_sessions.cpp | 6 ++--- .../test_select_from_with_timestamps.cpp | 6 ++--- tests/postgres/test_select_from_with_to.cpp | 6 ++--- tests/postgres/test_timestamp.cpp | 6 ++--- tests/postgres/test_timestamp_with_tz.cpp | 6 ++--- tests/postgres/test_transaction.cpp | 6 ++--- tests/postgres/test_union.cpp | 6 ++--- tests/postgres/test_union_all.cpp | 6 ++--- tests/postgres/test_union_in_join.cpp | 6 ++--- tests/postgres/test_union_in_join2.cpp | 6 ++--- tests/postgres/test_union_in_select.cpp | 6 ++--- tests/postgres/test_unique.cpp | 6 ++--- tests/postgres/test_update.cpp | 6 ++--- tests/postgres/test_update_with_optional.cpp | 6 ++--- tests/postgres/test_varchar.cpp | 6 ++--- tests/postgres/test_where.cpp | 6 ++--- tests/postgres/test_where_with_operations.cpp | 6 ++--- tests/postgres/test_where_with_timestamps.cpp | 6 ++--- tests/postgres/test_write_and_read.cpp | 6 ++--- .../postgres/test_write_and_read_curried.cpp | 6 ++--- tests/postgres/test_write_and_read_pool.cpp | 6 ++--- 70 files changed, 161 insertions(+), 292 deletions(-) create mode 100644 tests/postgres/test_helpers.hpp diff --git a/tests/postgres/test_aggregations.cpp b/tests/postgres/test_aggregations.cpp index fd2731ea..455803b7 100644 --- a/tests/postgres/test_aggregations.cpp +++ b/tests/postgres/test_aggregations.cpp @@ -8,6 +8,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_aggregations { @@ -27,10 +28,7 @@ TEST(postgres, test_aggregations) { Person{ .id = 3, .first_name = "Maggie", .last_name = "Simpson", .age = 0}}); - const auto credentials = sqlgen::postgres::Credentials{.user = "postgres", - .password = "password", - .host = "localhost", - .dbname = "postgres"}; + const auto credentials = sqlgen::postgres::test::make_credentials(); using namespace sqlgen; using namespace sqlgen::literals; diff --git a/tests/postgres/test_aggregations_with_nullable.cpp b/tests/postgres/test_aggregations_with_nullable.cpp index 5ca1da25..d55fb059 100644 --- a/tests/postgres/test_aggregations_with_nullable.cpp +++ b/tests/postgres/test_aggregations_with_nullable.cpp @@ -8,6 +8,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_aggregations_with_nullable { @@ -26,10 +27,7 @@ TEST(postgres, test_aggregations_with_nullable) { Person{.id = 2, .first_name = "Lisa", .last_name = "Simpson", .age = 8}, Person{.id = 3, .first_name = "Maggie", .last_name = "Simpson"}}); - const auto credentials = sqlgen::postgres::Credentials{.user = "postgres", - .password = "password", - .host = "localhost", - .dbname = "postgres"}; + const auto credentials = sqlgen::postgres::test::make_credentials(); using namespace sqlgen; using namespace sqlgen::literals; diff --git a/tests/postgres/test_auto_incr_primary_key.cpp b/tests/postgres/test_auto_incr_primary_key.cpp index 3422e890..5ba461ff 100644 --- a/tests/postgres/test_auto_incr_primary_key.cpp +++ b/tests/postgres/test_auto_incr_primary_key.cpp @@ -7,6 +7,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_auto_incr_primary_key { @@ -24,10 +25,7 @@ TEST(postgres, test_auto_incr_primary_key) { Person{.first_name = "Lisa", .last_name = "Simpson", .age = 8}, Person{.first_name = "Maggie", .last_name = "Simpson", .age = 0}}); - const auto credentials = sqlgen::postgres::Credentials{.user = "postgres", - .password = "password", - .host = "localhost", - .dbname = "postgres"}; + const auto credentials = sqlgen::postgres::test::make_credentials(); using namespace sqlgen; using namespace sqlgen::literals; diff --git a/tests/postgres/test_boolean.cpp b/tests/postgres/test_boolean.cpp index 59a79d2c..1406e240 100644 --- a/tests/postgres/test_boolean.cpp +++ b/tests/postgres/test_boolean.cpp @@ -7,6 +7,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_boolean { @@ -35,10 +36,7 @@ TEST(postgres, test_boolean) { .last_name = "Simpson", .has_children = false}}); - const auto credentials = sqlgen::postgres::Credentials{.user = "postgres", - .password = "password", - .host = "localhost", - .dbname = "postgres"}; + const auto credentials = sqlgen::postgres::test::make_credentials(); using namespace sqlgen; using namespace sqlgen::literals; diff --git a/tests/postgres/test_boolean_conditions.cpp b/tests/postgres/test_boolean_conditions.cpp index f0b4c6b4..d09b853e 100644 --- a/tests/postgres/test_boolean_conditions.cpp +++ b/tests/postgres/test_boolean_conditions.cpp @@ -7,6 +7,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_boolean_conditions { @@ -35,10 +36,7 @@ TEST(postgres, test_boolean_conditions) { .last_name = "Simpson", .has_children = false}}); - const auto credentials = sqlgen::postgres::Credentials{.user = "postgres", - .password = "password", - .host = "localhost", - .dbname = "postgres"}; + const auto credentials = sqlgen::postgres::test::make_credentials(); using namespace sqlgen; using namespace sqlgen::literals; diff --git a/tests/postgres/test_boolean_update.cpp b/tests/postgres/test_boolean_update.cpp index 69bdfb89..c3ac4244 100644 --- a/tests/postgres/test_boolean_update.cpp +++ b/tests/postgres/test_boolean_update.cpp @@ -7,6 +7,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_boolean_update { @@ -35,10 +36,7 @@ TEST(postgres, test_boolean_update) { .last_name = "Simpson", .has_children = false}}); - const auto credentials = sqlgen::postgres::Credentials{.user = "postgres", - .password = "password", - .host = "localhost", - .dbname = "postgres"}; + const auto credentials = sqlgen::postgres::test::make_credentials(); using namespace sqlgen; using namespace sqlgen::literals; diff --git a/tests/postgres/test_cache.cpp b/tests/postgres/test_cache.cpp index 5972206c..c38d2a08 100644 --- a/tests/postgres/test_cache.cpp +++ b/tests/postgres/test_cache.cpp @@ -7,6 +7,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_cache { @@ -16,10 +17,7 @@ struct User { }; TEST(postgres, test_cache) { - const auto credentials = sqlgen::postgres::Credentials{.user = "postgres", - .password = "password", - .host = "localhost", - .dbname = "postgres"}; + const auto credentials = sqlgen::postgres::test::make_credentials(); const auto conn = sqlgen::postgres::connect(credentials); diff --git a/tests/postgres/test_create_index.cpp b/tests/postgres/test_create_index.cpp index fb15f2bf..53422d13 100644 --- a/tests/postgres/test_create_index.cpp +++ b/tests/postgres/test_create_index.cpp @@ -7,6 +7,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_create_index { @@ -18,10 +19,7 @@ struct Person { }; TEST(postgres, test_create_index) { - const auto credentials = sqlgen::postgres::Credentials{.user = "postgres", - .password = "password", - .host = "localhost", - .dbname = "postgres"}; + const auto credentials = sqlgen::postgres::test::make_credentials(); using namespace sqlgen; using namespace sqlgen::literals; diff --git a/tests/postgres/test_create_index_where.cpp b/tests/postgres/test_create_index_where.cpp index 82268011..b765bff7 100644 --- a/tests/postgres/test_create_index_where.cpp +++ b/tests/postgres/test_create_index_where.cpp @@ -7,6 +7,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_create_index_where { @@ -18,10 +19,7 @@ struct Person { }; TEST(postgres, test_create_index_where) { - const auto credentials = sqlgen::postgres::Credentials{.user = "postgres", - .password = "password", - .host = "localhost", - .dbname = "postgres"}; + const auto credentials = sqlgen::postgres::test::make_credentials(); using namespace sqlgen; using namespace sqlgen::literals; diff --git a/tests/postgres/test_create_table.cpp b/tests/postgres/test_create_table.cpp index 7b61cd58..6ce244e6 100644 --- a/tests/postgres/test_create_table.cpp +++ b/tests/postgres/test_create_table.cpp @@ -7,6 +7,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_create_table { @@ -18,10 +19,7 @@ struct Person { }; TEST(postgres, test_create_table) { - const auto credentials = sqlgen::postgres::Credentials{.user = "postgres", - .password = "password", - .host = "localhost", - .dbname = "postgres"}; + const auto credentials = sqlgen::postgres::test::make_credentials(); using namespace sqlgen; using namespace sqlgen::literals; diff --git a/tests/postgres/test_create_table_as.cpp b/tests/postgres/test_create_table_as.cpp index 8d1fd199..93a06106 100644 --- a/tests/postgres/test_create_table_as.cpp +++ b/tests/postgres/test_create_table_as.cpp @@ -7,6 +7,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_create_table_as { @@ -23,10 +24,7 @@ struct Name { }; TEST(postgres, test_create_table_as) { - const auto credentials = sqlgen::postgres::Credentials{.user = "postgres", - .password = "password", - .host = "localhost", - .dbname = "postgres"}; + const auto credentials = sqlgen::postgres::test::make_credentials(); using namespace sqlgen; using namespace sqlgen::literals; diff --git a/tests/postgres/test_create_view_as.cpp b/tests/postgres/test_create_view_as.cpp index 092f9c41..1762f43d 100644 --- a/tests/postgres/test_create_view_as.cpp +++ b/tests/postgres/test_create_view_as.cpp @@ -7,6 +7,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_create_view_as { @@ -28,10 +29,7 @@ struct Name { }; TEST(postgres, test_create_view_as) { - const auto credentials = sqlgen::postgres::Credentials{.user = "postgres", - .password = "password", - .host = "localhost", - .dbname = "postgres"}; + const auto credentials = sqlgen::postgres::test::make_credentials(); using namespace sqlgen; using namespace sqlgen::literals; diff --git a/tests/postgres/test_delete_from.cpp b/tests/postgres/test_delete_from.cpp index c31ba579..10d1a7d3 100644 --- a/tests/postgres/test_delete_from.cpp +++ b/tests/postgres/test_delete_from.cpp @@ -7,6 +7,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_delete_from { @@ -28,10 +29,7 @@ TEST(postgres, test_delete_from) { Person{ .id = 4, .first_name = "Hugo", .last_name = "Simpson", .age = 10}}); - const auto credentials = sqlgen::postgres::Credentials{.user = "postgres", - .password = "password", - .host = "localhost", - .dbname = "postgres"}; + const auto credentials = sqlgen::postgres::test::make_credentials(); using namespace sqlgen; using namespace sqlgen::literals; diff --git a/tests/postgres/test_dynamic_type.cpp b/tests/postgres/test_dynamic_type.cpp index 1afeb23a..f835295b 100644 --- a/tests/postgres/test_dynamic_type.cpp +++ b/tests/postgres/test_dynamic_type.cpp @@ -11,6 +11,7 @@ #include #include #include +#include "test_helpers.hpp" namespace sqlgen::parsing { @@ -85,10 +86,7 @@ TEST(postgres, test_dynamic_type) { Person{.first_name = "Lisa", .last_name = "Simpson", .age = 8}, Person{.first_name = "Maggie", .last_name = "Simpson", .age = 0}}); - const auto credentials = sqlgen::postgres::Credentials{.user = "postgres", - .password = "password", - .host = "localhost", - .dbname = "postgres"}; + const auto credentials = sqlgen::postgres::test::make_credentials(); using namespace sqlgen; using namespace sqlgen::literals; diff --git a/tests/postgres/test_enum_crosstable.cpp b/tests/postgres/test_enum_crosstable.cpp index 460cb6ea..74315028 100644 --- a/tests/postgres/test_enum_crosstable.cpp +++ b/tests/postgres/test_enum_crosstable.cpp @@ -7,6 +7,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_enum_cross_table { enum class AccessRestriction { PUBLIC = 1, INTERNAL = 2, CONFIDENTIAL = 3 }; @@ -69,10 +70,7 @@ TEST(postgres, test_enum_cross_table) { .path = "/documents/powerplant/release_notes.txt"}, }); - const auto credentials = sqlgen::postgres::Credentials{.user = "postgres", - .password = "password", - .host = "localhost", - .dbname = "postgres"}; + const auto credentials = sqlgen::postgres::test::make_credentials(); const auto conn = postgres::connect(credentials); conn.and_then(drop | if_exists) .and_then(drop | if_exists); diff --git a/tests/postgres/test_enum_lookup.cpp b/tests/postgres/test_enum_lookup.cpp index 8a8d5bd9..918bcd4e 100644 --- a/tests/postgres/test_enum_lookup.cpp +++ b/tests/postgres/test_enum_lookup.cpp @@ -7,6 +7,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_enum_lookup { @@ -49,10 +50,7 @@ TEST(postgres, test_enum_lookup) { .path = "/documents/powerplant/release_notes.txt"}, }); - const auto credentials = sqlgen::postgres::Credentials{.user = "postgres", - .password = "password", - .host = "localhost", - .dbname = "postgres"}; + const auto credentials = sqlgen::postgres::test::make_credentials(); using namespace sqlgen; using namespace sqlgen::literals; diff --git a/tests/postgres/test_enum_namespace.cpp b/tests/postgres/test_enum_namespace.cpp index 86dfc47d..60385e42 100644 --- a/tests/postgres/test_enum_namespace.cpp +++ b/tests/postgres/test_enum_namespace.cpp @@ -7,6 +7,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_enum_namespace { namespace first { @@ -36,10 +37,7 @@ TEST(postgres, test_enum_namespace) { .enum_two = second::IdenticallyNamed::VALUE5}, }); - const auto credentials = sqlgen::postgres::Credentials{.user = "postgres", - .password = "password", - .host = "localhost", - .dbname = "postgres"}; + const auto credentials = sqlgen::postgres::test::make_credentials(); const auto conn = postgres::connect(credentials); conn.and_then(drop | if_exists); diff --git a/tests/postgres/test_error_handling.cpp b/tests/postgres/test_error_handling.cpp index 3f453241..d3adb349 100644 --- a/tests/postgres/test_error_handling.cpp +++ b/tests/postgres/test_error_handling.cpp @@ -7,6 +7,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_error_handling { @@ -28,10 +29,7 @@ TEST(postgres, test_error_handling) { Person{ .id = 4, .first_name = "Hugo", .last_name = "Simpson", .age = 10}}); - const auto credentials = sqlgen::postgres::Credentials{.user = "postgres", - .password = "password", - .host = "localhost", - .dbname = "postgres"}; + const auto credentials = sqlgen::postgres::test::make_credentials(); using namespace sqlgen; using namespace sqlgen::literals; diff --git a/tests/postgres/test_foreign_key.cpp b/tests/postgres/test_foreign_key.cpp index 22f17e65..2e2e921f 100644 --- a/tests/postgres/test_foreign_key.cpp +++ b/tests/postgres/test_foreign_key.cpp @@ -7,6 +7,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_foreign_key { @@ -39,10 +40,7 @@ TEST(postgres, test_foreign_key) { Relationship{.parent_id = 1, .child_id = 3}, Relationship{.parent_id = 1, .child_id = 4}}); - const auto credentials = sqlgen::postgres::Credentials{.user = "postgres", - .password = "password", - .host = "localhost", - .dbname = "postgres"}; + const auto credentials = sqlgen::postgres::test::make_credentials(); using namespace sqlgen; using namespace sqlgen::literals; diff --git a/tests/postgres/test_full_join.cpp b/tests/postgres/test_full_join.cpp index a828c81a..7eb21ac9 100644 --- a/tests/postgres/test_full_join.cpp +++ b/tests/postgres/test_full_join.cpp @@ -8,6 +8,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_full_join { @@ -37,10 +38,7 @@ TEST(postgres, test_full_join) { Pet{.id = 3, .name = "Mr. Teeny", .owner_id = 99}, }); - const auto credentials = sqlgen::postgres::Credentials{.user = "postgres", - .password = "password", - .host = "localhost", - .dbname = "postgres"}; + const auto credentials = sqlgen::postgres::test::make_credentials(); using namespace sqlgen; using namespace sqlgen::literals; diff --git a/tests/postgres/test_group_by.cpp b/tests/postgres/test_group_by.cpp index 2fa440f7..fa95acc1 100644 --- a/tests/postgres/test_group_by.cpp +++ b/tests/postgres/test_group_by.cpp @@ -8,6 +8,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_group_by { @@ -27,10 +28,7 @@ TEST(postgres, test_group_by) { Person{ .id = 3, .first_name = "Maggie", .last_name = "Simpson", .age = 0}}); - const auto credentials = sqlgen::postgres::Credentials{.user = "postgres", - .password = "password", - .host = "localhost", - .dbname = "postgres"}; + const auto credentials = sqlgen::postgres::test::make_credentials(); using namespace sqlgen; using namespace sqlgen::literals; diff --git a/tests/postgres/test_group_by_with_operations.cpp b/tests/postgres/test_group_by_with_operations.cpp index a670a282..a7f49197 100644 --- a/tests/postgres/test_group_by_with_operations.cpp +++ b/tests/postgres/test_group_by_with_operations.cpp @@ -8,6 +8,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_group_by_with_operations { @@ -27,10 +28,7 @@ TEST(postgres, test_group_by) { Person{ .id = 3, .first_name = "Maggie", .last_name = "Simpson", .age = 0}}); - const auto credentials = sqlgen::postgres::Credentials{.user = "postgres", - .password = "password", - .host = "localhost", - .dbname = "postgres"}; + const auto credentials = sqlgen::postgres::test::make_credentials(); using namespace sqlgen; using namespace sqlgen::literals; diff --git a/tests/postgres/test_helpers.hpp b/tests/postgres/test_helpers.hpp new file mode 100644 index 00000000..95541760 --- /dev/null +++ b/tests/postgres/test_helpers.hpp @@ -0,0 +1,19 @@ +#ifndef SQLGEN_TESTS_POSTGRES_TEST_HELPERS_HPP_ +#define SQLGEN_TESTS_POSTGRES_TEST_HELPERS_HPP_ + +#include +#include + +namespace sqlgen::postgres::test { + +inline Credentials make_credentials() { + const char* env_password = std::getenv("PGPASSWORD"); + return Credentials{.user = "postgres", + .password = env_password ? env_password : "password", + .host = "localhost", + .dbname = "postgres"}; +} + +} + +#endif diff --git a/tests/postgres/test_in.cpp b/tests/postgres/test_in.cpp index b48a0cd0..ac1eac7f 100644 --- a/tests/postgres/test_in.cpp +++ b/tests/postgres/test_in.cpp @@ -7,6 +7,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_in { @@ -28,10 +29,7 @@ TEST(postgres, test_in) { Person{ .id = 4, .first_name = "Hugo", .last_name = "Simpson", .age = 10}}); - const auto credentials = sqlgen::postgres::Credentials{.user = "postgres", - .password = "password", - .host = "localhost", - .dbname = "postgres"}; + const auto credentials = sqlgen::postgres::test::make_credentials(); using namespace sqlgen; using namespace sqlgen::literals; diff --git a/tests/postgres/test_in_vec.cpp b/tests/postgres/test_in_vec.cpp index d579eada..6864c2ae 100644 --- a/tests/postgres/test_in_vec.cpp +++ b/tests/postgres/test_in_vec.cpp @@ -7,6 +7,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_in_vec { @@ -28,10 +29,7 @@ TEST(postgres, test_in_vec) { Person{ .id = 4, .first_name = "Hugo", .last_name = "Simpson", .age = 10}}); - const auto credentials = sqlgen::postgres::Credentials{.user = "postgres", - .password = "password", - .host = "localhost", - .dbname = "postgres"}; + const auto credentials = sqlgen::postgres::test::make_credentials(); using namespace sqlgen; using namespace sqlgen::literals; diff --git a/tests/postgres/test_insert_and_read.cpp b/tests/postgres/test_insert_and_read.cpp index f01c637a..17688880 100644 --- a/tests/postgres/test_insert_and_read.cpp +++ b/tests/postgres/test_insert_and_read.cpp @@ -7,6 +7,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_insert_and_read { @@ -26,10 +27,7 @@ TEST(postgres, test_insert_and_read) { Person{ .id = 3, .first_name = "Maggie", .last_name = "Simpson", .age = 0}}); - const auto credentials = sqlgen::postgres::Credentials{.user = "postgres", - .password = "password", - .host = "localhost", - .dbname = "postgres"}; + const auto credentials = sqlgen::postgres::test::make_credentials(); using namespace sqlgen; using namespace sqlgen::literals; diff --git a/tests/postgres/test_insert_and_read_two_tables.cpp b/tests/postgres/test_insert_and_read_two_tables.cpp index 8fbf05d3..a883af0c 100644 --- a/tests/postgres/test_insert_and_read_two_tables.cpp +++ b/tests/postgres/test_insert_and_read_two_tables.cpp @@ -7,6 +7,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_insert_and_read_two_tables { @@ -36,10 +37,7 @@ TEST(postgres, test_insert_and_read_two_tables) { Children{.id_parent = 0, .id_child = 2}, Children{.id_parent = 0, .id_child = 3}}); - const auto credentials = sqlgen::postgres::Credentials{.user = "postgres", - .password = "password", - .host = "localhost", - .dbname = "postgres"}; + const auto credentials = sqlgen::postgres::test::make_credentials(); using namespace sqlgen; using namespace sqlgen::literals; diff --git a/tests/postgres/test_insert_fail.cpp b/tests/postgres/test_insert_fail.cpp index 38f52a61..338c16df 100644 --- a/tests/postgres/test_insert_fail.cpp +++ b/tests/postgres/test_insert_fail.cpp @@ -8,6 +8,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_insert_fail { @@ -27,10 +28,7 @@ TEST(postgres, test_insert_fail) { Person{ .id = 3, .first_name = "Maggie", .last_name = "Simpson", .age = 0}}); - const auto credentials = sqlgen::postgres::Credentials{.user = "postgres", - .password = "password", - .host = "localhost", - .dbname = "postgres"}; + const auto credentials = sqlgen::postgres::test::make_credentials(); using namespace sqlgen; using namespace sqlgen::literals; diff --git a/tests/postgres/test_insert_or_replace.cpp b/tests/postgres/test_insert_or_replace.cpp index c40864aa..4b76d3ca 100644 --- a/tests/postgres/test_insert_or_replace.cpp +++ b/tests/postgres/test_insert_or_replace.cpp @@ -7,6 +7,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_insert_or_replace { @@ -51,10 +52,7 @@ TEST(postgres, test_insert_or_replace) { using namespace sqlgen; using namespace sqlgen::literals; - const auto credentials = sqlgen::postgres::Credentials{.user = "postgres", - .password = "password", - .host = "localhost", - .dbname = "postgres"}; + const auto credentials = sqlgen::postgres::test::make_credentials(); const auto people4 = sqlgen::postgres::connect(credentials) diff --git a/tests/postgres/test_is_null.cpp b/tests/postgres/test_is_null.cpp index b444d554..853e77f1 100644 --- a/tests/postgres/test_is_null.cpp +++ b/tests/postgres/test_is_null.cpp @@ -7,6 +7,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_is_null { @@ -26,10 +27,7 @@ TEST(postgres, test_is_null) { .id = 3, .first_name = "Maggie", .last_name = "Simpson", .age = 0}, Person{.id = 4, .first_name = "Hugo", .last_name = "Simpson"}}); - const auto credentials = sqlgen::postgres::Credentials{.user = "postgres", - .password = "password", - .host = "localhost", - .dbname = "postgres"}; + const auto credentials = sqlgen::postgres::test::make_credentials(); using namespace sqlgen; using namespace sqlgen::literals; diff --git a/tests/postgres/test_join.cpp b/tests/postgres/test_join.cpp index df0071b5..126aa65a 100644 --- a/tests/postgres/test_join.cpp +++ b/tests/postgres/test_join.cpp @@ -8,6 +8,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_join { @@ -27,10 +28,7 @@ TEST(postgres, test_join) { Person{ .id = 3, .first_name = "Maggie", .last_name = "Simpson", .age = 0}}); - const auto credentials = sqlgen::postgres::Credentials{.user = "postgres", - .password = "password", - .host = "localhost", - .dbname = "postgres"}; + const auto credentials = sqlgen::postgres::test::make_credentials(); using namespace sqlgen; using namespace sqlgen::literals; diff --git a/tests/postgres/test_joins_from.cpp b/tests/postgres/test_joins_from.cpp index 7bf5a90e..1df0c7f5 100644 --- a/tests/postgres/test_joins_from.cpp +++ b/tests/postgres/test_joins_from.cpp @@ -8,6 +8,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_joins_from { @@ -42,10 +43,7 @@ TEST(postgres, test_joins_from) { Relationship{.parent_id = 1, .child_id = 3}, Relationship{.parent_id = 1, .child_id = 4}}); - const auto credentials = sqlgen::postgres::Credentials{.user = "postgres", - .password = "password", - .host = "localhost", - .dbname = "postgres"}; + const auto credentials = sqlgen::postgres::test::make_credentials(); using namespace sqlgen; using namespace sqlgen::literals; diff --git a/tests/postgres/test_joins_nested.cpp b/tests/postgres/test_joins_nested.cpp index 8ba6cd2c..31a7aae6 100644 --- a/tests/postgres/test_joins_nested.cpp +++ b/tests/postgres/test_joins_nested.cpp @@ -8,6 +8,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_joins_nested { @@ -42,10 +43,7 @@ TEST(postgres, test_joins_nested) { Relationship{.parent_id = 1, .child_id = 3}, Relationship{.parent_id = 1, .child_id = 4}}); - const auto credentials = sqlgen::postgres::Credentials{.user = "postgres", - .password = "password", - .host = "localhost", - .dbname = "postgres"}; + const auto credentials = sqlgen::postgres::test::make_credentials(); using namespace sqlgen; using namespace sqlgen::literals; diff --git a/tests/postgres/test_joins_nested_grouped.cpp b/tests/postgres/test_joins_nested_grouped.cpp index dd23f137..301fefef 100644 --- a/tests/postgres/test_joins_nested_grouped.cpp +++ b/tests/postgres/test_joins_nested_grouped.cpp @@ -8,6 +8,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_joins_nested_grouped { @@ -42,10 +43,7 @@ TEST(postgres, test_joins_nested_grouped) { Relationship{.parent_id = 1, .child_id = 3}, Relationship{.parent_id = 1, .child_id = 4}}); - const auto credentials = sqlgen::postgres::Credentials{.user = "postgres", - .password = "password", - .host = "localhost", - .dbname = "postgres"}; + const auto credentials = sqlgen::postgres::test::make_credentials(); using namespace sqlgen; using namespace sqlgen::literals; diff --git a/tests/postgres/test_joins_two_tables.cpp b/tests/postgres/test_joins_two_tables.cpp index 5faeb3d5..9b4ad508 100644 --- a/tests/postgres/test_joins_two_tables.cpp +++ b/tests/postgres/test_joins_two_tables.cpp @@ -8,6 +8,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_joins_two_tables { @@ -42,10 +43,7 @@ TEST(postgres, test_joins_two_tables) { Relationship{.parent_id = 1, .child_id = 3}, Relationship{.parent_id = 1, .child_id = 4}}); - const auto credentials = sqlgen::postgres::Credentials{.user = "postgres", - .password = "password", - .host = "localhost", - .dbname = "postgres"}; + const auto credentials = sqlgen::postgres::test::make_credentials(); using namespace sqlgen; using namespace sqlgen::literals; diff --git a/tests/postgres/test_joins_two_tables_grouped.cpp b/tests/postgres/test_joins_two_tables_grouped.cpp index 29b4e63c..4a8f18bf 100644 --- a/tests/postgres/test_joins_two_tables_grouped.cpp +++ b/tests/postgres/test_joins_two_tables_grouped.cpp @@ -8,6 +8,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_joins_two_tables_grouped { @@ -42,10 +43,7 @@ TEST(postgres, test_joins_two_tables_grouped) { Relationship{.parent_id = 1, .child_id = 3}, Relationship{.parent_id = 1, .child_id = 4}}); - const auto credentials = sqlgen::postgres::Credentials{.user = "postgres", - .password = "password", - .host = "localhost", - .dbname = "postgres"}; + const auto credentials = sqlgen::postgres::test::make_credentials(); using namespace sqlgen; using namespace sqlgen::literals; diff --git a/tests/postgres/test_json.cpp b/tests/postgres/test_json.cpp index 66c5155f..9bb0210b 100644 --- a/tests/postgres/test_json.cpp +++ b/tests/postgres/test_json.cpp @@ -7,6 +7,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_json { @@ -28,10 +29,7 @@ TEST(postgres, test_json) { .age = 45, .children = children}; - const auto credentials = sqlgen::postgres::Credentials{.user = "postgres", - .password = "password", - .host = "localhost", - .dbname = "postgres"}; + const auto credentials = sqlgen::postgres::test::make_credentials(); using namespace sqlgen; using namespace sqlgen::literals; diff --git a/tests/postgres/test_left_join.cpp b/tests/postgres/test_left_join.cpp index 01113f4c..aa413d22 100644 --- a/tests/postgres/test_left_join.cpp +++ b/tests/postgres/test_left_join.cpp @@ -8,6 +8,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_left_join { @@ -37,10 +38,7 @@ TEST(postgres, test_left_join) { Pet{.id = 3, .name = "Mr. Teeny", .owner_id = 99}, }); - const auto credentials = sqlgen::postgres::Credentials{.user = "postgres", - .password = "password", - .host = "localhost", - .dbname = "postgres"}; + const auto credentials = sqlgen::postgres::test::make_credentials(); using namespace sqlgen; using namespace sqlgen::literals; diff --git a/tests/postgres/test_like.cpp b/tests/postgres/test_like.cpp index 462a08d2..3a408ef0 100644 --- a/tests/postgres/test_like.cpp +++ b/tests/postgres/test_like.cpp @@ -7,6 +7,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_like { @@ -28,10 +29,7 @@ TEST(postgres, test_like) { Person{ .id = 4, .first_name = "Hugo", .last_name = "Simpson", .age = 10}}); - const auto credentials = sqlgen::postgres::Credentials{.user = "postgres", - .password = "password", - .host = "localhost", - .dbname = "postgres"}; + const auto credentials = sqlgen::postgres::test::make_credentials(); using namespace sqlgen; using namespace sqlgen::literals; diff --git a/tests/postgres/test_limit.cpp b/tests/postgres/test_limit.cpp index 6934490d..b9bc2704 100644 --- a/tests/postgres/test_limit.cpp +++ b/tests/postgres/test_limit.cpp @@ -7,6 +7,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_limit { @@ -28,10 +29,7 @@ TEST(postgres, test_limit) { Person{ .id = 4, .first_name = "Hugo", .last_name = "Simpson", .age = 10}}); - const auto credentials = sqlgen::postgres::Credentials{.user = "postgres", - .password = "password", - .host = "localhost", - .dbname = "postgres"}; + const auto credentials = sqlgen::postgres::test::make_credentials(); using namespace sqlgen; using namespace sqlgen::literals; diff --git a/tests/postgres/test_listen_notify.cpp b/tests/postgres/test_listen_notify.cpp index 73644b46..2861a89f 100644 --- a/tests/postgres/test_listen_notify.cpp +++ b/tests/postgres/test_listen_notify.cpp @@ -6,6 +6,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_listen_notify { @@ -35,10 +36,7 @@ TEST(postgres, basic_listen_notify) { using namespace sqlgen; using namespace sqlgen::postgres; - const auto credentials = sqlgen::postgres::Credentials{.user = "postgres", - .password = "password", - .host = "localhost", - .dbname = "postgres"}; + const auto credentials = sqlgen::postgres::test::make_credentials(); auto listener_result = sqlgen::postgres::connect(credentials); auto sender_result = sqlgen::postgres::connect(credentials); @@ -69,10 +67,7 @@ TEST(postgres, notify_without_listener_is_silent) { using namespace sqlgen; using namespace sqlgen::postgres; - const auto credentials = sqlgen::postgres::Credentials{.user = "postgres", - .password = "password", - .host = "localhost", - .dbname = "postgres"}; + const auto credentials = sqlgen::postgres::test::make_credentials(); auto sender_result = sqlgen::postgres::connect(credentials); @@ -89,10 +84,7 @@ TEST(postgres, InvalidChannelNameRejected) { using namespace sqlgen; using namespace sqlgen::postgres; - const auto credentials = sqlgen::postgres::Credentials{.user = "postgres", - .password = "password", - .host = "localhost", - .dbname = "postgres"}; + const auto credentials = sqlgen::postgres::test::make_credentials(); auto listener_result = sqlgen::postgres::connect(credentials); auto sender_result = sqlgen::postgres::connect(credentials); @@ -123,10 +115,7 @@ TEST(postgres, unlisten_star) { using namespace sqlgen; using namespace sqlgen::postgres; - const auto credentials = sqlgen::postgres::Credentials{.user = "postgres", - .password = "password", - .host = "localhost", - .dbname = "postgres"}; + const auto credentials = sqlgen::postgres::test::make_credentials(); auto listener_result = sqlgen::postgres::connect(credentials); @@ -149,10 +138,7 @@ TEST(postgres, multiple_notifications_in_burst) { using namespace sqlgen; using namespace sqlgen::postgres; - const auto credentials = sqlgen::postgres::Credentials{.user = "postgres", - .password = "password", - .host = "localhost", - .dbname = "postgres"}; + const auto credentials = sqlgen::postgres::test::make_credentials(); auto listener_result = sqlgen::postgres::connect(credentials); auto sender_result = sqlgen::postgres::connect(credentials); diff --git a/tests/postgres/test_not_in.cpp b/tests/postgres/test_not_in.cpp index 12ee8832..dd8009d7 100644 --- a/tests/postgres/test_not_in.cpp +++ b/tests/postgres/test_not_in.cpp @@ -7,6 +7,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_not_in { @@ -28,10 +29,7 @@ TEST(postgres, test_not_in) { Person{ .id = 4, .first_name = "Hugo", .last_name = "Simpson", .age = 10}}); - const auto credentials = sqlgen::postgres::Credentials{.user = "postgres", - .password = "password", - .host = "localhost", - .dbname = "postgres"}; + const auto credentials = sqlgen::postgres::test::make_credentials(); using namespace sqlgen; using namespace sqlgen::literals; diff --git a/tests/postgres/test_not_in_vec.cpp b/tests/postgres/test_not_in_vec.cpp index 2b52a569..52371de0 100644 --- a/tests/postgres/test_not_in_vec.cpp +++ b/tests/postgres/test_not_in_vec.cpp @@ -7,6 +7,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_not_in_vec { @@ -28,10 +29,7 @@ TEST(postgres, test_not_in_vec) { Person{ .id = 4, .first_name = "Hugo", .last_name = "Simpson", .age = 10}}); - const auto credentials = sqlgen::postgres::Credentials{.user = "postgres", - .password = "password", - .host = "localhost", - .dbname = "postgres"}; + const auto credentials = sqlgen::postgres::test::make_credentials(); using namespace sqlgen; using namespace sqlgen::literals; diff --git a/tests/postgres/test_offset.cpp b/tests/postgres/test_offset.cpp index 4900f16b..d31af87a 100644 --- a/tests/postgres/test_offset.cpp +++ b/tests/postgres/test_offset.cpp @@ -7,6 +7,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_offset { @@ -28,10 +29,7 @@ TEST(postgres, test_offset) { Person{ .id = 4, .first_name = "Hugo", .last_name = "Simpson", .age = 10}}); - const auto credentials = sqlgen::postgres::Credentials{.user = "postgres", - .password = "password", - .host = "localhost", - .dbname = "postgres"}; + const auto credentials = sqlgen::postgres::test::make_credentials(); using namespace sqlgen; using namespace sqlgen::literals; diff --git a/tests/postgres/test_operations.cpp b/tests/postgres/test_operations.cpp index ef338207..4d6030ca 100644 --- a/tests/postgres/test_operations.cpp +++ b/tests/postgres/test_operations.cpp @@ -8,6 +8,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_operations { @@ -27,10 +28,7 @@ TEST(postgres, test_operations) { Person{ .id = 3, .first_name = "Maggie", .last_name = "Simpson", .age = 0}}); - const auto credentials = sqlgen::postgres::Credentials{.user = "postgres", - .password = "password", - .host = "localhost", - .dbname = "postgres"}; + const auto credentials = sqlgen::postgres::test::make_credentials(); using namespace sqlgen; using namespace sqlgen::literals; diff --git a/tests/postgres/test_operations_with_nullable.cpp b/tests/postgres/test_operations_with_nullable.cpp index 191f871d..bc41380d 100644 --- a/tests/postgres/test_operations_with_nullable.cpp +++ b/tests/postgres/test_operations_with_nullable.cpp @@ -8,6 +8,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_operations_with_nullable { @@ -28,10 +29,7 @@ TEST(postgres, test_operations_with_nullable) { Person{ .id = 4, .first_name = "Maggie", .last_name = "Simpson", .age = 0}}); - const auto credentials = sqlgen::postgres::Credentials{.user = "postgres", - .password = "password", - .host = "localhost", - .dbname = "postgres"}; + const auto credentials = sqlgen::postgres::test::make_credentials(); using namespace sqlgen; using namespace sqlgen::literals; diff --git a/tests/postgres/test_range.cpp b/tests/postgres/test_range.cpp index 4d762901..26d9f234 100644 --- a/tests/postgres/test_range.cpp +++ b/tests/postgres/test_range.cpp @@ -8,6 +8,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_range { @@ -27,10 +28,7 @@ TEST(postgres, test_range) { Person{ .id = 3, .first_name = "Maggie", .last_name = "Simpson", .age = 0}}); - const auto credentials = sqlgen::postgres::Credentials{.user = "postgres", - .password = "password", - .host = "localhost", - .dbname = "postgres"}; + const auto credentials = sqlgen::postgres::test::make_credentials(); using namespace sqlgen; using namespace sqlgen::literals; diff --git a/tests/postgres/test_range_select_from.cpp b/tests/postgres/test_range_select_from.cpp index 20605981..12c67157 100644 --- a/tests/postgres/test_range_select_from.cpp +++ b/tests/postgres/test_range_select_from.cpp @@ -8,6 +8,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_range_select_from { @@ -27,10 +28,7 @@ TEST(postgres, test_range_select_from) { Person{ .id = 3, .first_name = "Maggie", .last_name = "Simpson", .age = 0}}); - const auto credentials = sqlgen::postgres::Credentials{.user = "postgres", - .password = "password", - .host = "localhost", - .dbname = "postgres"}; + const auto credentials = sqlgen::postgres::test::make_credentials(); using namespace sqlgen; using namespace sqlgen::literals; diff --git a/tests/postgres/test_right_join.cpp b/tests/postgres/test_right_join.cpp index 6f84f163..2f432b76 100644 --- a/tests/postgres/test_right_join.cpp +++ b/tests/postgres/test_right_join.cpp @@ -8,6 +8,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_right_join { @@ -37,10 +38,7 @@ TEST(postgres, test_right_join) { Pet{.id = 3, .name = "Mr. Teeny", .owner_id = 99}, }); - const auto credentials = sqlgen::postgres::Credentials{.user = "postgres", - .password = "password", - .host = "localhost", - .dbname = "postgres"}; + const auto credentials = sqlgen::postgres::test::make_credentials(); using namespace sqlgen; using namespace sqlgen::literals; diff --git a/tests/postgres/test_select_from_with_sessions.cpp b/tests/postgres/test_select_from_with_sessions.cpp index 32313717..1e998ea6 100644 --- a/tests/postgres/test_select_from_with_sessions.cpp +++ b/tests/postgres/test_select_from_with_sessions.cpp @@ -9,6 +9,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_range_select_from_with_sessions { @@ -36,10 +37,7 @@ TEST(postgres, test_range_select_from_with_sessions) { const auto pool_config = sqlgen::ConnectionPoolConfig{.size = 2}; - const auto credentials = sqlgen::postgres::Credentials{.user = "postgres", - .password = "password", - .host = "localhost", - .dbname = "postgres"}; + const auto credentials = sqlgen::postgres::test::make_credentials(); const auto pool = sqlgen::make_connection_pool( pool_config, credentials); diff --git a/tests/postgres/test_select_from_with_timestamps.cpp b/tests/postgres/test_select_from_with_timestamps.cpp index 88e910c6..479d69bb 100644 --- a/tests/postgres/test_select_from_with_timestamps.cpp +++ b/tests/postgres/test_select_from_with_timestamps.cpp @@ -9,6 +9,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_range_select_from_with_timestamps { @@ -34,10 +35,7 @@ TEST(postgres, test_range_select_from_with_timestamps) { .last_name = "Simpson", .birthday = sqlgen::Timestamp<"%Y-%m-%d">("2010-01-01")}}); - const auto credentials = sqlgen::postgres::Credentials{.user = "postgres", - .password = "password", - .host = "localhost", - .dbname = "postgres"}; + const auto credentials = sqlgen::postgres::test::make_credentials(); using namespace sqlgen; using namespace sqlgen::literals; diff --git a/tests/postgres/test_select_from_with_to.cpp b/tests/postgres/test_select_from_with_to.cpp index 9ed13421..ad19ab4c 100644 --- a/tests/postgres/test_select_from_with_to.cpp +++ b/tests/postgres/test_select_from_with_to.cpp @@ -8,6 +8,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_range_select_from_with_to { @@ -27,10 +28,7 @@ TEST(postgres, test_range_select_from) { Person{ .id = 3, .first_name = "Maggie", .last_name = "Simpson", .age = 0}}); - const auto credentials = sqlgen::postgres::Credentials{.user = "postgres", - .password = "password", - .host = "localhost", - .dbname = "postgres"}; + const auto credentials = sqlgen::postgres::test::make_credentials(); using namespace sqlgen; using namespace sqlgen::literals; diff --git a/tests/postgres/test_timestamp.cpp b/tests/postgres/test_timestamp.cpp index a955ef99..6fd76b00 100644 --- a/tests/postgres/test_timestamp.cpp +++ b/tests/postgres/test_timestamp.cpp @@ -5,6 +5,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_timestamp { @@ -25,10 +26,7 @@ TEST(postgres, test_timestamp) { using namespace sqlgen; using namespace sqlgen::literals; - const auto credentials = sqlgen::postgres::Credentials{.user = "postgres", - .password = "password", - .host = "localhost", - .dbname = "postgres"}; + const auto credentials = sqlgen::postgres::test::make_credentials(); const auto conn = sqlgen::postgres::connect(credentials).and_then(drop | if_exists); diff --git a/tests/postgres/test_timestamp_with_tz.cpp b/tests/postgres/test_timestamp_with_tz.cpp index 2abff86b..5552440c 100644 --- a/tests/postgres/test_timestamp_with_tz.cpp +++ b/tests/postgres/test_timestamp_with_tz.cpp @@ -5,6 +5,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_timestamp_with_tz { @@ -25,10 +26,7 @@ TEST(postgres, test_timestamp_with_tz) { using namespace sqlgen; using namespace sqlgen::literals; - const auto credentials = postgres::Credentials{.user = "postgres", - .password = "password", - .host = "localhost", - .dbname = "postgres"}; + const auto credentials = sqlgen::postgres::test::make_credentials(); const auto people2 = postgres::connect(credentials) .and_then(exec("SET TIME ZONE 'UTC';")) diff --git a/tests/postgres/test_transaction.cpp b/tests/postgres/test_transaction.cpp index 62ffdc9a..dbb39f5a 100644 --- a/tests/postgres/test_transaction.cpp +++ b/tests/postgres/test_transaction.cpp @@ -7,6 +7,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_transaction { @@ -28,10 +29,7 @@ TEST(postgres, test_transaction) { Person{ .id = 4, .first_name = "Hugo", .last_name = "Simpson", .age = 10}}); - const auto credentials = sqlgen::postgres::Credentials{.user = "postgres", - .password = "password", - .host = "localhost", - .dbname = "postgres"}; + const auto credentials = sqlgen::postgres::test::make_credentials(); using namespace sqlgen; using namespace sqlgen::literals; diff --git a/tests/postgres/test_union.cpp b/tests/postgres/test_union.cpp index 8ce15d49..9c53ef03 100644 --- a/tests/postgres/test_union.cpp +++ b/tests/postgres/test_union.cpp @@ -9,6 +9,7 @@ #include #include "sqlgen/postgres/to_sql.hpp" +#include "test_helpers.hpp" namespace test_union { @@ -30,10 +31,7 @@ struct User3 { TEST(postgres, test_union) { using namespace sqlgen::literals; - const auto credentials = sqlgen::postgres::Credentials{.user = "postgres", - .password = "password", - .host = "localhost", - .dbname = "postgres"}; + const auto credentials = sqlgen::postgres::test::make_credentials(); const auto conn = sqlgen::postgres::connect(credentials) .and_then(sqlgen::drop | sqlgen::if_exists) diff --git a/tests/postgres/test_union_all.cpp b/tests/postgres/test_union_all.cpp index 6190a7e1..80066e2e 100644 --- a/tests/postgres/test_union_all.cpp +++ b/tests/postgres/test_union_all.cpp @@ -9,6 +9,7 @@ #include #include "sqlgen/postgres/to_sql.hpp" +#include "test_helpers.hpp" namespace test_union_all { @@ -30,10 +31,7 @@ struct User3 { TEST(postgres, test_union_all) { using namespace sqlgen::literals; - const auto credentials = sqlgen::postgres::Credentials{.user = "postgres", - .password = "password", - .host = "localhost", - .dbname = "postgres"}; + const auto credentials = sqlgen::postgres::test::make_credentials(); const auto conn = sqlgen::postgres::connect(credentials) .and_then(sqlgen::drop | sqlgen::if_exists) diff --git a/tests/postgres/test_union_in_join.cpp b/tests/postgres/test_union_in_join.cpp index 910eb381..7320aaee 100644 --- a/tests/postgres/test_union_in_join.cpp +++ b/tests/postgres/test_union_in_join.cpp @@ -9,6 +9,7 @@ #include #include "sqlgen/postgres/to_sql.hpp" +#include "test_helpers.hpp" namespace test_union_in_join { @@ -36,10 +37,7 @@ TEST(postgres, test_union_in_join) { using namespace sqlgen; using namespace sqlgen::literals; - const auto credentials = sqlgen::postgres::Credentials{.user = "postgres", - .password = "password", - .host = "localhost", - .dbname = "postgres"}; + const auto credentials = sqlgen::postgres::test::make_credentials(); const auto conn = sqlgen::postgres::connect(credentials) .and_then(sqlgen::drop | sqlgen::if_exists) diff --git a/tests/postgres/test_union_in_join2.cpp b/tests/postgres/test_union_in_join2.cpp index 60ce6dfd..ffe74462 100644 --- a/tests/postgres/test_union_in_join2.cpp +++ b/tests/postgres/test_union_in_join2.cpp @@ -9,6 +9,7 @@ #include #include "sqlgen/postgres/to_sql.hpp" +#include "test_helpers.hpp" namespace test_union_in_join2 { @@ -36,10 +37,7 @@ TEST(postgres, test_union_in_join2) { using namespace sqlgen; using namespace sqlgen::literals; - const auto credentials = sqlgen::postgres::Credentials{.user = "postgres", - .password = "password", - .host = "localhost", - .dbname = "postgres"}; + const auto credentials = sqlgen::postgres::test::make_credentials(); const auto conn = sqlgen::postgres::connect(credentials) .and_then(sqlgen::drop | sqlgen::if_exists) diff --git a/tests/postgres/test_union_in_select.cpp b/tests/postgres/test_union_in_select.cpp index 51b219bc..14d47a7b 100644 --- a/tests/postgres/test_union_in_select.cpp +++ b/tests/postgres/test_union_in_select.cpp @@ -9,6 +9,7 @@ #include #include "sqlgen/postgres/to_sql.hpp" +#include "test_helpers.hpp" namespace test_union_in_select { @@ -30,10 +31,7 @@ struct User3 { TEST(postgres, test_union_in_select) { using namespace sqlgen::literals; - const auto credentials = sqlgen::postgres::Credentials{.user = "postgres", - .password = "password", - .host = "localhost", - .dbname = "postgres"}; + const auto credentials = sqlgen::postgres::test::make_credentials(); const auto conn = sqlgen::postgres::connect(credentials) .and_then(sqlgen::drop | sqlgen::if_exists) diff --git a/tests/postgres/test_unique.cpp b/tests/postgres/test_unique.cpp index 9c0ae777..54079351 100644 --- a/tests/postgres/test_unique.cpp +++ b/tests/postgres/test_unique.cpp @@ -8,6 +8,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_unique { @@ -29,10 +30,7 @@ TEST(postgres, test_unique) { Person{ .id = 4, .first_name = "Maggie", .last_name = "Simpson", .age = 0}}); - const auto credentials = sqlgen::postgres::Credentials{.user = "postgres", - .password = "password", - .host = "localhost", - .dbname = "postgres"}; + const auto credentials = sqlgen::postgres::test::make_credentials(); using namespace sqlgen; using namespace sqlgen::literals; diff --git a/tests/postgres/test_update.cpp b/tests/postgres/test_update.cpp index a3402400..b4c835d2 100644 --- a/tests/postgres/test_update.cpp +++ b/tests/postgres/test_update.cpp @@ -7,6 +7,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_update { @@ -28,10 +29,7 @@ TEST(postgres, test_update) { Person{ .id = 4, .first_name = "Hugo", .last_name = "Simpson", .age = 10}}); - const auto credentials = sqlgen::postgres::Credentials{.user = "postgres", - .password = "password", - .host = "localhost", - .dbname = "postgres"}; + const auto credentials = sqlgen::postgres::test::make_credentials(); using namespace sqlgen; using namespace sqlgen::literals; diff --git a/tests/postgres/test_update_with_optional.cpp b/tests/postgres/test_update_with_optional.cpp index ec1f2e7d..fca2e203 100644 --- a/tests/postgres/test_update_with_optional.cpp +++ b/tests/postgres/test_update_with_optional.cpp @@ -7,6 +7,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_update_with_optional { @@ -28,10 +29,7 @@ TEST(postgres, test_update_with_optional) { Person{ .id = 4, .first_name = "Hugo", .last_name = "Simpson", .age = 10}}); - const auto credentials = sqlgen::postgres::Credentials{.user = "postgres", - .password = "password", - .host = "localhost", - .dbname = "postgres"}; + const auto credentials = sqlgen::postgres::test::make_credentials(); using namespace sqlgen; using namespace sqlgen::literals; diff --git a/tests/postgres/test_varchar.cpp b/tests/postgres/test_varchar.cpp index 6f1367c9..da654da7 100644 --- a/tests/postgres/test_varchar.cpp +++ b/tests/postgres/test_varchar.cpp @@ -8,6 +8,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_varchar { @@ -27,10 +28,7 @@ TEST(postgres, test_varchar) { Person{ .id = 3, .first_name = "Maggie", .last_name = "Simpson", .age = 0}}); - const auto credentials = sqlgen::postgres::Credentials{.user = "postgres", - .password = "password", - .host = "localhost", - .dbname = "postgres"}; + const auto credentials = sqlgen::postgres::test::make_credentials(); using namespace sqlgen; using namespace sqlgen::literals; diff --git a/tests/postgres/test_where.cpp b/tests/postgres/test_where.cpp index b1dbb82c..c369910d 100644 --- a/tests/postgres/test_where.cpp +++ b/tests/postgres/test_where.cpp @@ -7,6 +7,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_where { @@ -28,10 +29,7 @@ TEST(postgres, test_where) { Person{ .id = 4, .first_name = "Hugo", .last_name = "Simpson", .age = 10}}); - const auto credentials = sqlgen::postgres::Credentials{.user = "postgres", - .password = "password", - .host = "localhost", - .dbname = "postgres"}; + const auto credentials = sqlgen::postgres::test::make_credentials(); using namespace sqlgen; using namespace sqlgen::literals; diff --git a/tests/postgres/test_where_with_operations.cpp b/tests/postgres/test_where_with_operations.cpp index 188f2c9d..8d6b9d1a 100644 --- a/tests/postgres/test_where_with_operations.cpp +++ b/tests/postgres/test_where_with_operations.cpp @@ -7,6 +7,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_where_with_operations { @@ -28,10 +29,7 @@ TEST(postgres, test_where_with_operations) { Person{ .id = 4, .first_name = "Hugo", .last_name = "Simpson", .age = 10}}); - const auto credentials = sqlgen::postgres::Credentials{.user = "postgres", - .password = "password", - .host = "localhost", - .dbname = "postgres"}; + const auto credentials = sqlgen::postgres::test::make_credentials(); using namespace sqlgen; using namespace sqlgen::literals; diff --git a/tests/postgres/test_where_with_timestamps.cpp b/tests/postgres/test_where_with_timestamps.cpp index b6c7d0c7..f3dabbf5 100644 --- a/tests/postgres/test_where_with_timestamps.cpp +++ b/tests/postgres/test_where_with_timestamps.cpp @@ -8,6 +8,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_where_with_timestamps { @@ -33,10 +34,7 @@ TEST(postgres, test_where_with_timestamps) { .last_name = "Simpson", .birthday = sqlgen::Date("2010-01-01")}}); - const auto credentials = sqlgen::postgres::Credentials{.user = "postgres", - .password = "password", - .host = "localhost", - .dbname = "postgres"}; + const auto credentials = sqlgen::postgres::test::make_credentials(); using namespace sqlgen; using namespace sqlgen::literals; diff --git a/tests/postgres/test_write_and_read.cpp b/tests/postgres/test_write_and_read.cpp index cc96c77d..631cde9e 100644 --- a/tests/postgres/test_write_and_read.cpp +++ b/tests/postgres/test_write_and_read.cpp @@ -7,6 +7,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_write_and_read { @@ -26,10 +27,7 @@ TEST(postgres, test_write_and_read) { Person{ .id = 3, .first_name = "Maggie", .last_name = "Simpson", .age = 0}}); - const auto credentials = sqlgen::postgres::Credentials{.user = "postgres", - .password = "password", - .host = "localhost", - .dbname = "postgres"}; + const auto credentials = sqlgen::postgres::test::make_credentials(); using namespace sqlgen; using namespace sqlgen::literals; diff --git a/tests/postgres/test_write_and_read_curried.cpp b/tests/postgres/test_write_and_read_curried.cpp index de57bac0..50dbbea3 100644 --- a/tests/postgres/test_write_and_read_curried.cpp +++ b/tests/postgres/test_write_and_read_curried.cpp @@ -7,6 +7,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_write_and_read_curried { @@ -26,10 +27,7 @@ TEST(postgres, test_write_and_read_curried) { Person{ .id = 3, .first_name = "Maggie", .last_name = "Simpson", .age = 0}}); - const auto credentials = sqlgen::postgres::Credentials{.user = "postgres", - .password = "password", - .host = "localhost", - .dbname = "postgres"}; + const auto credentials = sqlgen::postgres::test::make_credentials(); using namespace sqlgen; using namespace sqlgen::literals; diff --git a/tests/postgres/test_write_and_read_pool.cpp b/tests/postgres/test_write_and_read_pool.cpp index c9e34c96..adb5fd04 100644 --- a/tests/postgres/test_write_and_read_pool.cpp +++ b/tests/postgres/test_write_and_read_pool.cpp @@ -7,6 +7,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_write_and_read_pool { @@ -28,10 +29,7 @@ TEST(postgres, test_write_and_read_pool) { const auto pool_config = sqlgen::ConnectionPoolConfig{.size = 2}; - const auto credentials = sqlgen::postgres::Credentials{.user = "postgres", - .password = "password", - .host = "localhost", - .dbname = "postgres"}; + const auto credentials = sqlgen::postgres::test::make_credentials(); const auto pool = sqlgen::make_connection_pool( pool_config, credentials); From 267459e570efbc14e529a8e288f8ed2484ac9ad0 Mon Sep 17 00:00:00 2001 From: Marco Craveiro Date: Thu, 5 Feb 2026 10:15:49 +0000 Subject: [PATCH 2/3] Use SQLGEN_TEST_PASSWORD env var for mysql test credentials Add test_helpers.hpp with make_credentials() that checks for SQLGEN_TEST_PASSWORD environment variable, falling back to "password" if not set. Follows the same pattern as postgres tests. Co-Authored-By: Claude Opus 4.5 --- tests/mysql/test_aggregations.cpp | 6 ++---- .../mysql/test_aggregations_with_nullable.cpp | 6 ++---- tests/mysql/test_auto_incr_primary_key.cpp | 6 ++---- tests/mysql/test_boolean.cpp | 6 ++---- tests/mysql/test_boolean_conditions.cpp | 6 ++---- tests/mysql/test_boolean_update.cpp | 6 ++---- tests/mysql/test_cache.cpp | 6 ++---- tests/mysql/test_create_index.cpp | 6 ++---- tests/mysql/test_create_table.cpp | 6 ++---- tests/mysql/test_create_table_as.cpp | 6 ++---- tests/mysql/test_create_view_as.cpp | 6 ++---- tests/mysql/test_delete_from.cpp | 6 ++---- tests/mysql/test_dynamic_type.cpp | 6 ++---- tests/mysql/test_enum_crosstable.cpp | 6 ++---- tests/mysql/test_enum_lookup.cpp | 6 ++---- tests/mysql/test_enum_namespace.cpp | 6 ++---- tests/mysql/test_error_handling.cpp | 6 ++---- tests/mysql/test_foreign_key.cpp | 6 ++---- tests/mysql/test_group_by.cpp | 6 ++---- tests/mysql/test_group_by_with_operations.cpp | 6 ++---- tests/mysql/test_helpers.hpp | 19 +++++++++++++++++++ tests/mysql/test_in.cpp | 6 ++---- tests/mysql/test_in_vec.cpp | 6 ++---- tests/mysql/test_insert_and_read.cpp | 6 ++---- .../mysql/test_insert_and_read_two_tables.cpp | 6 ++---- tests/mysql/test_insert_fail.cpp | 6 ++---- tests/mysql/test_insert_or_replace.cpp | 6 ++---- tests/mysql/test_is_null.cpp | 6 ++---- tests/mysql/test_join.cpp | 6 ++---- tests/mysql/test_joins_from.cpp | 6 ++---- tests/mysql/test_joins_nested.cpp | 6 ++---- tests/mysql/test_joins_nested_grouped.cpp | 6 ++---- tests/mysql/test_joins_two_tables.cpp | 6 ++---- tests/mysql/test_joins_two_tables_grouped.cpp | 6 ++---- tests/mysql/test_json.cpp | 6 ++---- tests/mysql/test_left_join.cpp | 6 ++---- tests/mysql/test_like.cpp | 6 ++---- tests/mysql/test_limit.cpp | 6 ++---- tests/mysql/test_not_in.cpp | 6 ++---- tests/mysql/test_not_in_vec.cpp | 6 ++---- tests/mysql/test_offset.cpp | 6 ++---- tests/mysql/test_operations.cpp | 6 ++---- tests/mysql/test_operations_with_nullable.cpp | 6 ++---- tests/mysql/test_range.cpp | 6 ++---- tests/mysql/test_range_select_from.cpp | 6 ++---- tests/mysql/test_right_join.cpp | 6 ++---- .../test_select_from_with_timestamps.cpp | 6 ++---- tests/mysql/test_select_from_with_to.cpp | 6 ++---- tests/mysql/test_timestamp.cpp | 6 ++---- tests/mysql/test_transaction.cpp | 6 ++---- tests/mysql/test_union.cpp | 6 ++---- tests/mysql/test_union_all.cpp | 6 ++---- tests/mysql/test_union_in_join.cpp | 6 ++---- tests/mysql/test_union_in_join2.cpp | 6 ++---- tests/mysql/test_union_in_select.cpp | 6 ++---- tests/mysql/test_unique.cpp | 6 ++---- tests/mysql/test_update.cpp | 6 ++---- tests/mysql/test_update_with_optional.cpp | 6 ++---- tests/mysql/test_varchar.cpp | 6 ++---- tests/mysql/test_where.cpp | 6 ++---- tests/mysql/test_where_with_operations.cpp | 6 ++---- tests/mysql/test_where_with_timestamps.cpp | 6 ++---- tests/mysql/test_write_and_read.cpp | 6 ++---- tests/mysql/test_write_and_read_curried.cpp | 6 ++---- tests/mysql/test_write_and_read_pool.cpp | 6 ++---- 65 files changed, 147 insertions(+), 256 deletions(-) create mode 100644 tests/mysql/test_helpers.hpp diff --git a/tests/mysql/test_aggregations.cpp b/tests/mysql/test_aggregations.cpp index 3fb89e54..ab2f8bbe 100644 --- a/tests/mysql/test_aggregations.cpp +++ b/tests/mysql/test_aggregations.cpp @@ -8,6 +8,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_aggregations { @@ -27,10 +28,7 @@ TEST(mysql, test_aggregations) { Person{ .id = 3, .first_name = "Maggie", .last_name = "Simpson", .age = 0}}); - const auto credentials = sqlgen::mysql::Credentials{.host = "localhost", - .user = "sqlgen", - .password = "password", - .dbname = "mysql"}; + const auto credentials = sqlgen::mysql::test::make_credentials(); using namespace sqlgen; using namespace sqlgen::literals; diff --git a/tests/mysql/test_aggregations_with_nullable.cpp b/tests/mysql/test_aggregations_with_nullable.cpp index ad2415ad..908f79f6 100644 --- a/tests/mysql/test_aggregations_with_nullable.cpp +++ b/tests/mysql/test_aggregations_with_nullable.cpp @@ -8,6 +8,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_aggregations_with_nullable { @@ -26,10 +27,7 @@ TEST(mysql, test_aggregations_with_nullable) { Person{.id = 2, .first_name = "Lisa", .last_name = "Simpson", .age = 8}, Person{.id = 3, .first_name = "Maggie", .last_name = "Simpson"}}); - const auto credentials = sqlgen::mysql::Credentials{.host = "localhost", - .user = "sqlgen", - .password = "password", - .dbname = "mysql"}; + const auto credentials = sqlgen::mysql::test::make_credentials(); using namespace sqlgen; using namespace sqlgen::literals; diff --git a/tests/mysql/test_auto_incr_primary_key.cpp b/tests/mysql/test_auto_incr_primary_key.cpp index 0173c219..1376e1d2 100644 --- a/tests/mysql/test_auto_incr_primary_key.cpp +++ b/tests/mysql/test_auto_incr_primary_key.cpp @@ -7,6 +7,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_auto_incr_primary_key { @@ -24,10 +25,7 @@ TEST(mysql, test_auto_incr_primary_key) { Person{.first_name = "Lisa", .last_name = "Simpson", .age = 8}, Person{.first_name = "Maggie", .last_name = "Simpson", .age = 0}}); - const auto credentials = sqlgen::mysql::Credentials{.host = "localhost", - .user = "sqlgen", - .password = "password", - .dbname = "mysql"}; + const auto credentials = sqlgen::mysql::test::make_credentials(); using namespace sqlgen; using namespace sqlgen::literals; diff --git a/tests/mysql/test_boolean.cpp b/tests/mysql/test_boolean.cpp index fbf643c2..216936b2 100644 --- a/tests/mysql/test_boolean.cpp +++ b/tests/mysql/test_boolean.cpp @@ -7,6 +7,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_boolean { @@ -35,10 +36,7 @@ TEST(mysql, test_boolean) { .last_name = "Simpson", .has_children = false}}); - const auto credentials = sqlgen::mysql::Credentials{.host = "localhost", - .user = "sqlgen", - .password = "password", - .dbname = "mysql"}; + const auto credentials = sqlgen::mysql::test::make_credentials(); using namespace sqlgen; using namespace sqlgen::literals; diff --git a/tests/mysql/test_boolean_conditions.cpp b/tests/mysql/test_boolean_conditions.cpp index 8efc3946..4f2040ea 100644 --- a/tests/mysql/test_boolean_conditions.cpp +++ b/tests/mysql/test_boolean_conditions.cpp @@ -7,6 +7,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_boolean_conditions { @@ -35,10 +36,7 @@ TEST(mysql, test_boolean_conditions) { .last_name = "Simpson", .has_children = false}}); - const auto credentials = sqlgen::mysql::Credentials{.host = "localhost", - .user = "sqlgen", - .password = "password", - .dbname = "mysql"}; + const auto credentials = sqlgen::mysql::test::make_credentials(); using namespace sqlgen; using namespace sqlgen::literals; diff --git a/tests/mysql/test_boolean_update.cpp b/tests/mysql/test_boolean_update.cpp index d3d313b6..343939f9 100644 --- a/tests/mysql/test_boolean_update.cpp +++ b/tests/mysql/test_boolean_update.cpp @@ -7,6 +7,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_boolean_update { @@ -35,10 +36,7 @@ TEST(mysql, test_boolean_update) { .last_name = "Simpson", .has_children = false}}); - const auto credentials = sqlgen::mysql::Credentials{.host = "localhost", - .user = "sqlgen", - .password = "password", - .dbname = "mysql"}; + const auto credentials = sqlgen::mysql::test::make_credentials(); using namespace sqlgen; using namespace sqlgen::literals; diff --git a/tests/mysql/test_cache.cpp b/tests/mysql/test_cache.cpp index cd54cae6..b088e10b 100644 --- a/tests/mysql/test_cache.cpp +++ b/tests/mysql/test_cache.cpp @@ -7,6 +7,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_cache { @@ -16,10 +17,7 @@ struct User { }; TEST(mysql, test_cache) { - const auto credentials = sqlgen::mysql::Credentials{.host = "localhost", - .user = "sqlgen", - .password = "password", - .dbname = "mysql"}; + const auto credentials = sqlgen::mysql::test::make_credentials(); const auto conn = sqlgen::mysql::connect(credentials); diff --git a/tests/mysql/test_create_index.cpp b/tests/mysql/test_create_index.cpp index 73b48436..acecaec1 100644 --- a/tests/mysql/test_create_index.cpp +++ b/tests/mysql/test_create_index.cpp @@ -7,6 +7,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_create_index { @@ -18,10 +19,7 @@ struct Person { }; TEST(mysql, test_create_index) { - const auto credentials = sqlgen::mysql::Credentials{.host = "localhost", - .user = "sqlgen", - .password = "password", - .dbname = "mysql"}; + const auto credentials = sqlgen::mysql::test::make_credentials(); using namespace sqlgen; using namespace sqlgen::literals; diff --git a/tests/mysql/test_create_table.cpp b/tests/mysql/test_create_table.cpp index d8698224..9b991cba 100644 --- a/tests/mysql/test_create_table.cpp +++ b/tests/mysql/test_create_table.cpp @@ -7,6 +7,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_create_table { @@ -18,10 +19,7 @@ struct Person { }; TEST(mysql, test_create_table) { - const auto credentials = sqlgen::mysql::Credentials{.host = "localhost", - .user = "sqlgen", - .password = "password", - .dbname = "mysql"}; + const auto credentials = sqlgen::mysql::test::make_credentials(); using namespace sqlgen; using namespace sqlgen::literals; diff --git a/tests/mysql/test_create_table_as.cpp b/tests/mysql/test_create_table_as.cpp index 07aaf433..ef1c1f42 100644 --- a/tests/mysql/test_create_table_as.cpp +++ b/tests/mysql/test_create_table_as.cpp @@ -7,6 +7,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_create_table_as { @@ -23,10 +24,7 @@ struct Name { }; TEST(mysql, test_create_table_as) { - const auto credentials = sqlgen::mysql::Credentials{.host = "localhost", - .user = "sqlgen", - .password = "password", - .dbname = "mysql"}; + const auto credentials = sqlgen::mysql::test::make_credentials(); using namespace sqlgen; using namespace sqlgen::literals; diff --git a/tests/mysql/test_create_view_as.cpp b/tests/mysql/test_create_view_as.cpp index 6e75b8bd..5d795b8d 100644 --- a/tests/mysql/test_create_view_as.cpp +++ b/tests/mysql/test_create_view_as.cpp @@ -7,6 +7,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_create_view_as { @@ -28,10 +29,7 @@ struct Name { }; TEST(mysql, test_create_view_as) { - const auto credentials = sqlgen::mysql::Credentials{.host = "localhost", - .user = "sqlgen", - .password = "password", - .dbname = "mysql"}; + const auto credentials = sqlgen::mysql::test::make_credentials(); using namespace sqlgen; using namespace sqlgen::literals; diff --git a/tests/mysql/test_delete_from.cpp b/tests/mysql/test_delete_from.cpp index 104cca61..d5484fbf 100644 --- a/tests/mysql/test_delete_from.cpp +++ b/tests/mysql/test_delete_from.cpp @@ -7,6 +7,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_delete_from { @@ -28,10 +29,7 @@ TEST(mysql, test_delete_from) { Person{ .id = 4, .first_name = "Hugo", .last_name = "Simpson", .age = 10}}); - const auto credentials = sqlgen::mysql::Credentials{.host = "localhost", - .user = "sqlgen", - .password = "password", - .dbname = "mysql"}; + const auto credentials = sqlgen::mysql::test::make_credentials(); using namespace sqlgen; using namespace sqlgen::literals; diff --git a/tests/mysql/test_dynamic_type.cpp b/tests/mysql/test_dynamic_type.cpp index 9be5ab7d..11bae962 100644 --- a/tests/mysql/test_dynamic_type.cpp +++ b/tests/mysql/test_dynamic_type.cpp @@ -11,6 +11,7 @@ #include #include #include +#include "test_helpers.hpp" namespace sqlgen::parsing { @@ -85,10 +86,7 @@ TEST(mysql, test_dynamic_type) { Person{.first_name = "Lisa", .last_name = "Simpson", .age = 8}, Person{.first_name = "Maggie", .last_name = "Simpson", .age = 0}}); - const auto credentials = sqlgen::mysql::Credentials{.host = "localhost", - .user = "sqlgen", - .password = "password", - .dbname = "mysql"}; + const auto credentials = sqlgen::mysql::test::make_credentials(); using namespace sqlgen; using namespace sqlgen::literals; diff --git a/tests/mysql/test_enum_crosstable.cpp b/tests/mysql/test_enum_crosstable.cpp index dbbcead7..37ea8997 100644 --- a/tests/mysql/test_enum_crosstable.cpp +++ b/tests/mysql/test_enum_crosstable.cpp @@ -7,6 +7,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_enum_cross_table { enum class AccessRestriction { PUBLIC = 1, INTERNAL = 2, CONFIDENTIAL = 3 }; @@ -69,10 +70,7 @@ TEST(mysql, test_enum_cross_table) { .path = "/documents/powerplant/release_notes.txt"}, }); - const auto credentials = sqlgen::mysql::Credentials{.host = "localhost", - .user = "sqlgen", - .password = "password", - .dbname = "mysql"}; + const auto credentials = sqlgen::mysql::test::make_credentials(); const auto conn = mysql::connect(credentials); conn.and_then(drop | if_exists) .and_then(drop | if_exists); diff --git a/tests/mysql/test_enum_lookup.cpp b/tests/mysql/test_enum_lookup.cpp index 6c8b89e3..5bf6afd5 100644 --- a/tests/mysql/test_enum_lookup.cpp +++ b/tests/mysql/test_enum_lookup.cpp @@ -7,6 +7,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_enum_lookup { @@ -49,10 +50,7 @@ TEST(mysql, test_enum_lookup) { .path = "/documents/powerplant/release_notes.txt"}, }); - const auto credentials = sqlgen::mysql::Credentials{.host = "localhost", - .user = "sqlgen", - .password = "password", - .dbname = "mysql"}; + const auto credentials = sqlgen::mysql::test::make_credentials(); using namespace sqlgen; using namespace sqlgen::literals; diff --git a/tests/mysql/test_enum_namespace.cpp b/tests/mysql/test_enum_namespace.cpp index 28ff5f74..9b343acc 100644 --- a/tests/mysql/test_enum_namespace.cpp +++ b/tests/mysql/test_enum_namespace.cpp @@ -7,6 +7,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_enum_namespace { namespace first { @@ -36,10 +37,7 @@ TEST(mysql, test_enum_namespace) { .enum_two = second::IdenticallyNamed::VALUE5}, }); - const auto credentials = sqlgen::mysql::Credentials{.host = "localhost", - .user = "sqlgen", - .password = "password", - .dbname = "mysql"}; + const auto credentials = sqlgen::mysql::test::make_credentials(); const auto conn = mysql::connect(credentials); conn.and_then(drop | if_exists); diff --git a/tests/mysql/test_error_handling.cpp b/tests/mysql/test_error_handling.cpp index 94410cc2..7cc48201 100644 --- a/tests/mysql/test_error_handling.cpp +++ b/tests/mysql/test_error_handling.cpp @@ -7,6 +7,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_error_handling { @@ -28,10 +29,7 @@ TEST(mysql, test_error_handling) { Person{ .id = 4, .first_name = "Hugo", .last_name = "Simpson", .age = 10}}); - const auto credentials = sqlgen::mysql::Credentials{.host = "localhost", - .user = "sqlgen", - .password = "password", - .dbname = "mysql"}; + const auto credentials = sqlgen::mysql::test::make_credentials(); using namespace sqlgen; using namespace sqlgen::literals; diff --git a/tests/mysql/test_foreign_key.cpp b/tests/mysql/test_foreign_key.cpp index 07c3cb54..1a613e64 100644 --- a/tests/mysql/test_foreign_key.cpp +++ b/tests/mysql/test_foreign_key.cpp @@ -7,6 +7,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_foreign_key { @@ -39,10 +40,7 @@ TEST(mysql, test_foreign_key) { Relationship{.parent_id = 1, .child_id = 3}, Relationship{.parent_id = 1, .child_id = 4}}); - const auto credentials = sqlgen::mysql::Credentials{.host = "localhost", - .user = "sqlgen", - .password = "password", - .dbname = "mysql"}; + const auto credentials = sqlgen::mysql::test::make_credentials(); using namespace sqlgen; using namespace sqlgen::literals; diff --git a/tests/mysql/test_group_by.cpp b/tests/mysql/test_group_by.cpp index d20fef35..40824516 100644 --- a/tests/mysql/test_group_by.cpp +++ b/tests/mysql/test_group_by.cpp @@ -8,6 +8,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_group_by { @@ -27,10 +28,7 @@ TEST(mysql, test_group_by) { Person{ .id = 3, .first_name = "Maggie", .last_name = "Simpson", .age = 0}}); - const auto credentials = sqlgen::mysql::Credentials{.host = "localhost", - .user = "sqlgen", - .password = "password", - .dbname = "mysql"}; + const auto credentials = sqlgen::mysql::test::make_credentials(); using namespace sqlgen; using namespace sqlgen::literals; diff --git a/tests/mysql/test_group_by_with_operations.cpp b/tests/mysql/test_group_by_with_operations.cpp index 1e403085..3519d906 100644 --- a/tests/mysql/test_group_by_with_operations.cpp +++ b/tests/mysql/test_group_by_with_operations.cpp @@ -8,6 +8,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_group_by_with_operations { @@ -27,10 +28,7 @@ TEST(mysql, test_group_by_with_operations) { Person{ .id = 3, .first_name = "Maggie", .last_name = "Simpson", .age = 0}}); - const auto credentials = sqlgen::mysql::Credentials{.host = "localhost", - .user = "sqlgen", - .password = "password", - .dbname = "mysql"}; + const auto credentials = sqlgen::mysql::test::make_credentials(); using namespace sqlgen; using namespace sqlgen::literals; diff --git a/tests/mysql/test_helpers.hpp b/tests/mysql/test_helpers.hpp new file mode 100644 index 00000000..0b9bc763 --- /dev/null +++ b/tests/mysql/test_helpers.hpp @@ -0,0 +1,19 @@ +#ifndef SQLGEN_TESTS_MYSQL_TEST_HELPERS_HPP_ +#define SQLGEN_TESTS_MYSQL_TEST_HELPERS_HPP_ + +#include +#include + +namespace sqlgen::mysql::test { + +inline Credentials make_credentials() { + const char* env_password = std::getenv("SQLGEN_TEST_PASSWORD"); + return Credentials{.host = "localhost", + .user = "sqlgen", + .password = env_password ? env_password : "password", + .dbname = "mysql"}; +} + +} + +#endif diff --git a/tests/mysql/test_in.cpp b/tests/mysql/test_in.cpp index a9a73e0e..702ed712 100644 --- a/tests/mysql/test_in.cpp +++ b/tests/mysql/test_in.cpp @@ -7,6 +7,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_in { @@ -28,10 +29,7 @@ TEST(mysql, test_in) { Person{ .id = 4, .first_name = "Hugo", .last_name = "Simpson", .age = 10}}); - const auto credentials = sqlgen::mysql::Credentials{.host = "localhost", - .user = "sqlgen", - .password = "password", - .dbname = "mysql"}; + const auto credentials = sqlgen::mysql::test::make_credentials(); using namespace sqlgen; using namespace sqlgen::literals; diff --git a/tests/mysql/test_in_vec.cpp b/tests/mysql/test_in_vec.cpp index 5be0906a..6a663114 100644 --- a/tests/mysql/test_in_vec.cpp +++ b/tests/mysql/test_in_vec.cpp @@ -7,6 +7,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_in_vec { @@ -28,10 +29,7 @@ TEST(mysql, test_in_vec) { Person{ .id = 4, .first_name = "Hugo", .last_name = "Simpson", .age = 10}}); - const auto credentials = sqlgen::mysql::Credentials{.host = "localhost", - .user = "sqlgen", - .password = "password", - .dbname = "mysql"}; + const auto credentials = sqlgen::mysql::test::make_credentials(); using namespace sqlgen; using namespace sqlgen::literals; diff --git a/tests/mysql/test_insert_and_read.cpp b/tests/mysql/test_insert_and_read.cpp index 9ebf1ab3..eb8c761b 100644 --- a/tests/mysql/test_insert_and_read.cpp +++ b/tests/mysql/test_insert_and_read.cpp @@ -7,6 +7,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_insert_and_read { @@ -26,10 +27,7 @@ TEST(mysql, test_insert_and_read) { Person{ .id = 3, .first_name = "Maggie", .last_name = "Simpson", .age = 0}}); - const auto credentials = sqlgen::mysql::Credentials{.host = "localhost", - .user = "sqlgen", - .password = "password", - .dbname = "mysql"}; + const auto credentials = sqlgen::mysql::test::make_credentials(); using namespace sqlgen; using namespace sqlgen::literals; diff --git a/tests/mysql/test_insert_and_read_two_tables.cpp b/tests/mysql/test_insert_and_read_two_tables.cpp index ad8a436d..410154dc 100644 --- a/tests/mysql/test_insert_and_read_two_tables.cpp +++ b/tests/mysql/test_insert_and_read_two_tables.cpp @@ -7,6 +7,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_insert_and_read_two_tables { @@ -36,10 +37,7 @@ TEST(mysql, test_insert_and_read_two_tables) { Children{.id_parent = 0, .id_child = 2}, Children{.id_parent = 0, .id_child = 3}}); - const auto credentials = sqlgen::mysql::Credentials{.host = "localhost", - .user = "sqlgen", - .password = "password", - .dbname = "mysql"}; + const auto credentials = sqlgen::mysql::test::make_credentials(); using namespace sqlgen; using namespace sqlgen::literals; diff --git a/tests/mysql/test_insert_fail.cpp b/tests/mysql/test_insert_fail.cpp index 2b10ec6a..d38d46f5 100644 --- a/tests/mysql/test_insert_fail.cpp +++ b/tests/mysql/test_insert_fail.cpp @@ -8,6 +8,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_insert_fail { @@ -27,10 +28,7 @@ TEST(mysql, test_insert_fail) { Person{ .id = 3, .first_name = "Maggie", .last_name = "Simpson", .age = 0}}); - const auto credentials = sqlgen::mysql::Credentials{.host = "localhost", - .user = "sqlgen", - .password = "password", - .dbname = "mysql"}; + const auto credentials = sqlgen::mysql::test::make_credentials(); using namespace sqlgen; using namespace sqlgen::literals; diff --git a/tests/mysql/test_insert_or_replace.cpp b/tests/mysql/test_insert_or_replace.cpp index ed3da72b..079c3a34 100644 --- a/tests/mysql/test_insert_or_replace.cpp +++ b/tests/mysql/test_insert_or_replace.cpp @@ -7,6 +7,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_insert_or_replace { @@ -51,10 +52,7 @@ TEST(mysql, test_insert_or_replace) { using namespace sqlgen; using namespace sqlgen::literals; - const auto credentials = sqlgen::mysql::Credentials{.host = "localhost", - .user = "sqlgen", - .password = "password", - .dbname = "mysql"}; + const auto credentials = sqlgen::mysql::test::make_credentials(); const auto people4 = sqlgen::mysql::connect(credentials) diff --git a/tests/mysql/test_is_null.cpp b/tests/mysql/test_is_null.cpp index 211c72bb..6aed6705 100644 --- a/tests/mysql/test_is_null.cpp +++ b/tests/mysql/test_is_null.cpp @@ -7,6 +7,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_is_null { @@ -26,10 +27,7 @@ TEST(mysql, test_is_null) { .id = 3, .first_name = "Maggie", .last_name = "Simpson", .age = 0}, Person{.id = 4, .first_name = "Hugo", .last_name = "Simpson"}}); - const auto credentials = sqlgen::mysql::Credentials{.host = "localhost", - .user = "sqlgen", - .password = "password", - .dbname = "mysql"}; + const auto credentials = sqlgen::mysql::test::make_credentials(); using namespace sqlgen; using namespace sqlgen::literals; diff --git a/tests/mysql/test_join.cpp b/tests/mysql/test_join.cpp index 13fe86d1..eefb6901 100644 --- a/tests/mysql/test_join.cpp +++ b/tests/mysql/test_join.cpp @@ -8,6 +8,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_join { @@ -27,10 +28,7 @@ TEST(mysql, test_join) { Person{ .id = 3, .first_name = "Maggie", .last_name = "Simpson", .age = 0}}); - const auto credentials = sqlgen::mysql::Credentials{.host = "localhost", - .user = "sqlgen", - .password = "password", - .dbname = "mysql"}; + const auto credentials = sqlgen::mysql::test::make_credentials(); using namespace sqlgen; using namespace sqlgen::literals; diff --git a/tests/mysql/test_joins_from.cpp b/tests/mysql/test_joins_from.cpp index 8a5054a8..9433d313 100644 --- a/tests/mysql/test_joins_from.cpp +++ b/tests/mysql/test_joins_from.cpp @@ -8,6 +8,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_joins_from { @@ -42,10 +43,7 @@ TEST(mysql, test_joins_from) { Relationship{.parent_id = 1, .child_id = 3}, Relationship{.parent_id = 1, .child_id = 4}}); - const auto credentials = sqlgen::mysql::Credentials{.host = "localhost", - .user = "sqlgen", - .password = "password", - .dbname = "mysql"}; + const auto credentials = sqlgen::mysql::test::make_credentials(); using namespace sqlgen; using namespace sqlgen::literals; diff --git a/tests/mysql/test_joins_nested.cpp b/tests/mysql/test_joins_nested.cpp index 09829f09..290e29c7 100644 --- a/tests/mysql/test_joins_nested.cpp +++ b/tests/mysql/test_joins_nested.cpp @@ -8,6 +8,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_joins_nested { @@ -42,10 +43,7 @@ TEST(mysql, test_joins_nested) { Relationship{.parent_id = 1, .child_id = 3}, Relationship{.parent_id = 1, .child_id = 4}}); - const auto credentials = sqlgen::mysql::Credentials{.host = "localhost", - .user = "sqlgen", - .password = "password", - .dbname = "mysql"}; + const auto credentials = sqlgen::mysql::test::make_credentials(); using namespace sqlgen; using namespace sqlgen::literals; diff --git a/tests/mysql/test_joins_nested_grouped.cpp b/tests/mysql/test_joins_nested_grouped.cpp index b1e5d91c..73f8d696 100644 --- a/tests/mysql/test_joins_nested_grouped.cpp +++ b/tests/mysql/test_joins_nested_grouped.cpp @@ -8,6 +8,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_joins_nested_grouped { @@ -42,10 +43,7 @@ TEST(mysql, test_joins_nested_grouped) { Relationship{.parent_id = 1, .child_id = 3}, Relationship{.parent_id = 1, .child_id = 4}}); - const auto credentials = sqlgen::mysql::Credentials{.host = "localhost", - .user = "sqlgen", - .password = "password", - .dbname = "mysql"}; + const auto credentials = sqlgen::mysql::test::make_credentials(); using namespace sqlgen; using namespace sqlgen::literals; diff --git a/tests/mysql/test_joins_two_tables.cpp b/tests/mysql/test_joins_two_tables.cpp index bed3892d..13558435 100644 --- a/tests/mysql/test_joins_two_tables.cpp +++ b/tests/mysql/test_joins_two_tables.cpp @@ -8,6 +8,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_joins_two_tables { @@ -42,10 +43,7 @@ TEST(mysql, test_joins_two_tables) { Relationship{.parent_id = 1, .child_id = 3}, Relationship{.parent_id = 1, .child_id = 4}}); - const auto credentials = sqlgen::mysql::Credentials{.host = "localhost", - .user = "sqlgen", - .password = "password", - .dbname = "mysql"}; + const auto credentials = sqlgen::mysql::test::make_credentials(); using namespace sqlgen; using namespace sqlgen::literals; diff --git a/tests/mysql/test_joins_two_tables_grouped.cpp b/tests/mysql/test_joins_two_tables_grouped.cpp index b0729b92..d8642119 100644 --- a/tests/mysql/test_joins_two_tables_grouped.cpp +++ b/tests/mysql/test_joins_two_tables_grouped.cpp @@ -8,6 +8,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_joins_two_tables_grouped { @@ -42,10 +43,7 @@ TEST(mysql, test_joins_two_tables_grouped) { Relationship{.parent_id = 1, .child_id = 3}, Relationship{.parent_id = 1, .child_id = 4}}); - const auto credentials = sqlgen::mysql::Credentials{.host = "localhost", - .user = "sqlgen", - .password = "password", - .dbname = "mysql"}; + const auto credentials = sqlgen::mysql::test::make_credentials(); using namespace sqlgen; using namespace sqlgen::literals; diff --git a/tests/mysql/test_json.cpp b/tests/mysql/test_json.cpp index a4a3243c..e59ea527 100644 --- a/tests/mysql/test_json.cpp +++ b/tests/mysql/test_json.cpp @@ -7,6 +7,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_json { @@ -28,10 +29,7 @@ TEST(mysql, test_json) { .age = 45, .children = children}; - const auto credentials = sqlgen::mysql::Credentials{.host = "localhost", - .user = "sqlgen", - .password = "password", - .dbname = "mysql"}; + const auto credentials = sqlgen::mysql::test::make_credentials(); using namespace sqlgen; using namespace sqlgen::literals; diff --git a/tests/mysql/test_left_join.cpp b/tests/mysql/test_left_join.cpp index fdaf9720..9578f7af 100644 --- a/tests/mysql/test_left_join.cpp +++ b/tests/mysql/test_left_join.cpp @@ -8,6 +8,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_left_join { @@ -37,10 +38,7 @@ TEST(mysql, test_left_join) { Pet{.id = 3, .name = "Mr. Teeny", .owner_id = 99}, }); - const auto credentials = sqlgen::mysql::Credentials{.host = "localhost", - .user = "sqlgen", - .password = "password", - .dbname = "mysql"}; + const auto credentials = sqlgen::mysql::test::make_credentials(); using namespace sqlgen; using namespace sqlgen::literals; diff --git a/tests/mysql/test_like.cpp b/tests/mysql/test_like.cpp index e63515ad..5172e4ed 100644 --- a/tests/mysql/test_like.cpp +++ b/tests/mysql/test_like.cpp @@ -7,6 +7,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_like { @@ -28,10 +29,7 @@ TEST(mysql, test_like) { Person{ .id = 4, .first_name = "Hugo", .last_name = "Simpson", .age = 10}}); - const auto credentials = sqlgen::mysql::Credentials{.host = "localhost", - .user = "sqlgen", - .password = "password", - .dbname = "mysql"}; + const auto credentials = sqlgen::mysql::test::make_credentials(); using namespace sqlgen; using namespace sqlgen::literals; diff --git a/tests/mysql/test_limit.cpp b/tests/mysql/test_limit.cpp index 22f46c21..e7e11828 100644 --- a/tests/mysql/test_limit.cpp +++ b/tests/mysql/test_limit.cpp @@ -7,6 +7,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_limit { @@ -28,10 +29,7 @@ TEST(mysql, test_limit) { Person{ .id = 4, .first_name = "Hugo", .last_name = "Simpson", .age = 10}}); - const auto credentials = sqlgen::mysql::Credentials{.host = "localhost", - .user = "sqlgen", - .password = "password", - .dbname = "mysql"}; + const auto credentials = sqlgen::mysql::test::make_credentials(); using namespace sqlgen; using namespace sqlgen::literals; diff --git a/tests/mysql/test_not_in.cpp b/tests/mysql/test_not_in.cpp index af0d47f4..0541dfae 100644 --- a/tests/mysql/test_not_in.cpp +++ b/tests/mysql/test_not_in.cpp @@ -7,6 +7,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_not_in { @@ -28,10 +29,7 @@ TEST(mysql, test_not_in) { Person{ .id = 4, .first_name = "Hugo", .last_name = "Simpson", .age = 10}}); - const auto credentials = sqlgen::mysql::Credentials{.host = "localhost", - .user = "sqlgen", - .password = "password", - .dbname = "mysql"}; + const auto credentials = sqlgen::mysql::test::make_credentials(); using namespace sqlgen; using namespace sqlgen::literals; diff --git a/tests/mysql/test_not_in_vec.cpp b/tests/mysql/test_not_in_vec.cpp index 3328a256..2fe638ac 100644 --- a/tests/mysql/test_not_in_vec.cpp +++ b/tests/mysql/test_not_in_vec.cpp @@ -7,6 +7,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_not_in_vec { @@ -28,10 +29,7 @@ TEST(mysql, test_not_in_vec) { Person{ .id = 4, .first_name = "Hugo", .last_name = "Simpson", .age = 10}}); - const auto credentials = sqlgen::mysql::Credentials{.host = "localhost", - .user = "sqlgen", - .password = "password", - .dbname = "mysql"}; + const auto credentials = sqlgen::mysql::test::make_credentials(); using namespace sqlgen; using namespace sqlgen::literals; diff --git a/tests/mysql/test_offset.cpp b/tests/mysql/test_offset.cpp index 7bd857d6..22494697 100644 --- a/tests/mysql/test_offset.cpp +++ b/tests/mysql/test_offset.cpp @@ -7,6 +7,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_offset { @@ -28,10 +29,7 @@ TEST(mysql, test_offset) { Person{ .id = 4, .first_name = "Hugo", .last_name = "Simpson", .age = 10}}); - const auto credentials = sqlgen::mysql::Credentials{.host = "localhost", - .user = "sqlgen", - .password = "password", - .dbname = "mysql"}; + const auto credentials = sqlgen::mysql::test::make_credentials(); using namespace sqlgen; using namespace sqlgen::literals; diff --git a/tests/mysql/test_operations.cpp b/tests/mysql/test_operations.cpp index 9739dbb9..2562cfea 100644 --- a/tests/mysql/test_operations.cpp +++ b/tests/mysql/test_operations.cpp @@ -8,6 +8,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_operations { @@ -27,10 +28,7 @@ TEST(mysql, test_operations) { Person{ .id = 3, .first_name = "Maggie", .last_name = "Simpson", .age = 0}}); - const auto credentials = sqlgen::mysql::Credentials{.host = "localhost", - .user = "sqlgen", - .password = "password", - .dbname = "mysql"}; + const auto credentials = sqlgen::mysql::test::make_credentials(); using namespace sqlgen; using namespace sqlgen::literals; diff --git a/tests/mysql/test_operations_with_nullable.cpp b/tests/mysql/test_operations_with_nullable.cpp index aa568dfa..5593921e 100644 --- a/tests/mysql/test_operations_with_nullable.cpp +++ b/tests/mysql/test_operations_with_nullable.cpp @@ -8,6 +8,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_operations_with_nullable { @@ -28,10 +29,7 @@ TEST(mysql, test_operations_with_nullable) { Person{ .id = 4, .first_name = "Maggie", .last_name = "Simpson", .age = 0}}); - const auto credentials = sqlgen::mysql::Credentials{.host = "localhost", - .user = "sqlgen", - .password = "password", - .dbname = "mysql"}; + const auto credentials = sqlgen::mysql::test::make_credentials(); using namespace sqlgen; using namespace sqlgen::literals; diff --git a/tests/mysql/test_range.cpp b/tests/mysql/test_range.cpp index 2accd13d..4b8bda45 100644 --- a/tests/mysql/test_range.cpp +++ b/tests/mysql/test_range.cpp @@ -8,6 +8,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_range { @@ -27,10 +28,7 @@ TEST(mysql, test_range) { Person{ .id = 3, .first_name = "Maggie", .last_name = "Simpson", .age = 0}}); - const auto credentials = sqlgen::mysql::Credentials{.host = "localhost", - .user = "sqlgen", - .password = "password", - .dbname = "mysql"}; + const auto credentials = sqlgen::mysql::test::make_credentials(); using namespace sqlgen; using namespace sqlgen::literals; diff --git a/tests/mysql/test_range_select_from.cpp b/tests/mysql/test_range_select_from.cpp index 5a9e81ed..86f1e9e6 100644 --- a/tests/mysql/test_range_select_from.cpp +++ b/tests/mysql/test_range_select_from.cpp @@ -8,6 +8,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_range_select_from { @@ -27,10 +28,7 @@ TEST(mysql, test_range_select_from) { Person{ .id = 3, .first_name = "Maggie", .last_name = "Simpson", .age = 0}}); - const auto credentials = sqlgen::mysql::Credentials{.host = "localhost", - .user = "sqlgen", - .password = "password", - .dbname = "mysql"}; + const auto credentials = sqlgen::mysql::test::make_credentials(); using namespace sqlgen; using namespace sqlgen::literals; diff --git a/tests/mysql/test_right_join.cpp b/tests/mysql/test_right_join.cpp index 719b67f1..f60cbfa8 100644 --- a/tests/mysql/test_right_join.cpp +++ b/tests/mysql/test_right_join.cpp @@ -8,6 +8,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_right_join { @@ -37,10 +38,7 @@ TEST(mysql, test_right_join) { Pet{.id = 3, .name = "Mr. Teeny", .owner_id = 99}, }); - const auto credentials = sqlgen::mysql::Credentials{.host = "localhost", - .user = "sqlgen", - .password = "password", - .dbname = "mysql"}; + const auto credentials = sqlgen::mysql::test::make_credentials(); using namespace sqlgen; using namespace sqlgen::literals; diff --git a/tests/mysql/test_select_from_with_timestamps.cpp b/tests/mysql/test_select_from_with_timestamps.cpp index 449d3b29..10bd8ddc 100644 --- a/tests/mysql/test_select_from_with_timestamps.cpp +++ b/tests/mysql/test_select_from_with_timestamps.cpp @@ -9,6 +9,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_select_from_with_timestamps { @@ -34,10 +35,7 @@ TEST(mysql, test_select_from_with_timestamps) { .last_name = "Simpson", .birthday = sqlgen::Date("2010-01-01")}}); - const auto credentials = sqlgen::mysql::Credentials{.host = "localhost", - .user = "sqlgen", - .password = "password", - .dbname = "mysql"}; + const auto credentials = sqlgen::mysql::test::make_credentials(); using namespace sqlgen; using namespace sqlgen::literals; diff --git a/tests/mysql/test_select_from_with_to.cpp b/tests/mysql/test_select_from_with_to.cpp index 44948c2d..f87e67e9 100644 --- a/tests/mysql/test_select_from_with_to.cpp +++ b/tests/mysql/test_select_from_with_to.cpp @@ -8,6 +8,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_range_select_from_with_to { @@ -27,10 +28,7 @@ TEST(mysql, test_range_select_from) { Person{ .id = 3, .first_name = "Maggie", .last_name = "Simpson", .age = 0}}); - const auto credentials = sqlgen::mysql::Credentials{.host = "localhost", - .user = "sqlgen", - .password = "password", - .dbname = "mysql"}; + const auto credentials = sqlgen::mysql::test::make_credentials(); using namespace sqlgen; using namespace sqlgen::literals; diff --git a/tests/mysql/test_timestamp.cpp b/tests/mysql/test_timestamp.cpp index e33f6900..fc972d26 100644 --- a/tests/mysql/test_timestamp.cpp +++ b/tests/mysql/test_timestamp.cpp @@ -5,6 +5,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_timestamp { @@ -25,10 +26,7 @@ TEST(mysql, test_timestamp) { using namespace sqlgen; using namespace sqlgen::literals; - const auto credentials = sqlgen::mysql::Credentials{.host = "localhost", - .user = "sqlgen", - .password = "password", - .dbname = "mysql"}; + const auto credentials = sqlgen::mysql::test::make_credentials(); const auto conn = sqlgen::mysql::connect(credentials).and_then(drop | if_exists); diff --git a/tests/mysql/test_transaction.cpp b/tests/mysql/test_transaction.cpp index 46abbd45..c99d72f6 100644 --- a/tests/mysql/test_transaction.cpp +++ b/tests/mysql/test_transaction.cpp @@ -7,6 +7,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_transaction { @@ -28,10 +29,7 @@ TEST(mysql, test_transaction) { Person{ .id = 4, .first_name = "Hugo", .last_name = "Simpson", .age = 10}}); - const auto credentials = sqlgen::mysql::Credentials{.host = "localhost", - .user = "sqlgen", - .password = "password", - .dbname = "mysql"}; + const auto credentials = sqlgen::mysql::test::make_credentials(); using namespace sqlgen; using namespace sqlgen::literals; diff --git a/tests/mysql/test_union.cpp b/tests/mysql/test_union.cpp index b51d66e7..d0ad446c 100644 --- a/tests/mysql/test_union.cpp +++ b/tests/mysql/test_union.cpp @@ -7,6 +7,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_union { @@ -28,10 +29,7 @@ struct User3 { TEST(mysql, test_union) { using namespace sqlgen::literals; - const auto credentials = sqlgen::mysql::Credentials{.host = "localhost", - .user = "sqlgen", - .password = "password", - .dbname = "mysql"}; + const auto credentials = sqlgen::mysql::test::make_credentials(); const auto conn = sqlgen::mysql::connect(credentials) .and_then(sqlgen::drop | sqlgen::if_exists) diff --git a/tests/mysql/test_union_all.cpp b/tests/mysql/test_union_all.cpp index 0c656626..1cab57c8 100644 --- a/tests/mysql/test_union_all.cpp +++ b/tests/mysql/test_union_all.cpp @@ -9,6 +9,7 @@ #include #include "sqlgen/mysql/to_sql.hpp" +#include "test_helpers.hpp" namespace test_union_all { @@ -30,10 +31,7 @@ struct User3 { TEST(mysql, test_union_all) { using namespace sqlgen::literals; - const auto credentials = sqlgen::mysql::Credentials{.host = "localhost", - .user = "sqlgen", - .password = "password", - .dbname = "mysql"}; + const auto credentials = sqlgen::mysql::test::make_credentials(); const auto conn = sqlgen::mysql::connect(credentials) .and_then(sqlgen::drop | sqlgen::if_exists) diff --git a/tests/mysql/test_union_in_join.cpp b/tests/mysql/test_union_in_join.cpp index a644275b..1a958f8a 100644 --- a/tests/mysql/test_union_in_join.cpp +++ b/tests/mysql/test_union_in_join.cpp @@ -9,6 +9,7 @@ #include #include "sqlgen/mysql/to_sql.hpp" +#include "test_helpers.hpp" namespace test_union_in_join { @@ -36,10 +37,7 @@ TEST(mysql, test_union_in_join) { using namespace sqlgen; using namespace sqlgen::literals; - const auto credentials = sqlgen::mysql::Credentials{.host = "localhost", - .user = "sqlgen", - .password = "password", - .dbname = "mysql"}; + const auto credentials = sqlgen::mysql::test::make_credentials(); const auto conn = sqlgen::mysql::connect(credentials) .and_then(sqlgen::drop | sqlgen::if_exists) diff --git a/tests/mysql/test_union_in_join2.cpp b/tests/mysql/test_union_in_join2.cpp index e52599a7..ddfb4ecb 100644 --- a/tests/mysql/test_union_in_join2.cpp +++ b/tests/mysql/test_union_in_join2.cpp @@ -9,6 +9,7 @@ #include #include "sqlgen/mysql/to_sql.hpp" +#include "test_helpers.hpp" namespace test_union_in_join2 { @@ -36,10 +37,7 @@ TEST(mysql, test_union_in_join2) { using namespace sqlgen; using namespace sqlgen::literals; - const auto credentials = sqlgen::mysql::Credentials{.host = "localhost", - .user = "sqlgen", - .password = "password", - .dbname = "mysql"}; + const auto credentials = sqlgen::mysql::test::make_credentials(); const auto conn = sqlgen::mysql::connect(credentials) .and_then(sqlgen::drop | sqlgen::if_exists) diff --git a/tests/mysql/test_union_in_select.cpp b/tests/mysql/test_union_in_select.cpp index e3ce3891..f90d064b 100644 --- a/tests/mysql/test_union_in_select.cpp +++ b/tests/mysql/test_union_in_select.cpp @@ -9,6 +9,7 @@ #include #include "sqlgen/mysql/to_sql.hpp" +#include "test_helpers.hpp" namespace test_union_in_select { @@ -30,10 +31,7 @@ struct User3 { TEST(mysql, test_union_in_select) { using namespace sqlgen::literals; - const auto credentials = sqlgen::mysql::Credentials{.host = "localhost", - .user = "sqlgen", - .password = "password", - .dbname = "mysql"}; + const auto credentials = sqlgen::mysql::test::make_credentials(); const auto conn = sqlgen::mysql::connect(credentials) .and_then(sqlgen::drop | sqlgen::if_exists) diff --git a/tests/mysql/test_unique.cpp b/tests/mysql/test_unique.cpp index 868179fe..ad7dc468 100644 --- a/tests/mysql/test_unique.cpp +++ b/tests/mysql/test_unique.cpp @@ -8,6 +8,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_unique { @@ -29,10 +30,7 @@ TEST(mysql, test_unique) { Person{ .id = 4, .first_name = "Maggie", .last_name = "Simpson", .age = 0}}); - const auto credentials = sqlgen::mysql::Credentials{.host = "localhost", - .user = "sqlgen", - .password = "password", - .dbname = "mysql"}; + const auto credentials = sqlgen::mysql::test::make_credentials(); using namespace sqlgen; using namespace sqlgen::literals; diff --git a/tests/mysql/test_update.cpp b/tests/mysql/test_update.cpp index 0489d771..5ef809ef 100644 --- a/tests/mysql/test_update.cpp +++ b/tests/mysql/test_update.cpp @@ -7,6 +7,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_update { @@ -28,10 +29,7 @@ TEST(mysql, test_update) { Person{ .id = 4, .first_name = "Hugo", .last_name = "Simpson", .age = 10}}); - const auto credentials = sqlgen::mysql::Credentials{.host = "localhost", - .user = "sqlgen", - .password = "password", - .dbname = "mysql"}; + const auto credentials = sqlgen::mysql::test::make_credentials(); using namespace sqlgen; using namespace sqlgen::literals; diff --git a/tests/mysql/test_update_with_optional.cpp b/tests/mysql/test_update_with_optional.cpp index df6fd23e..ad3c6296 100644 --- a/tests/mysql/test_update_with_optional.cpp +++ b/tests/mysql/test_update_with_optional.cpp @@ -7,6 +7,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_update_with_optional { @@ -28,10 +29,7 @@ TEST(mysql, test_update_with_optional) { Person{ .id = 4, .first_name = "Hugo", .last_name = "Simpson", .age = 10}}); - const auto credentials = sqlgen::mysql::Credentials{.host = "localhost", - .user = "sqlgen", - .password = "password", - .dbname = "mysql"}; + const auto credentials = sqlgen::mysql::test::make_credentials(); using namespace sqlgen; using namespace sqlgen::literals; diff --git a/tests/mysql/test_varchar.cpp b/tests/mysql/test_varchar.cpp index be22cef4..bcc73e77 100644 --- a/tests/mysql/test_varchar.cpp +++ b/tests/mysql/test_varchar.cpp @@ -8,6 +8,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_varchar { @@ -27,10 +28,7 @@ TEST(mysql, test_varchar) { Person{ .id = 3, .first_name = "Maggie", .last_name = "Simpson", .age = 0}}); - const auto credentials = sqlgen::mysql::Credentials{.host = "localhost", - .user = "sqlgen", - .password = "password", - .dbname = "mysql"}; + const auto credentials = sqlgen::mysql::test::make_credentials(); using namespace sqlgen; using namespace sqlgen::literals; diff --git a/tests/mysql/test_where.cpp b/tests/mysql/test_where.cpp index 08da07aa..c27a306e 100644 --- a/tests/mysql/test_where.cpp +++ b/tests/mysql/test_where.cpp @@ -7,6 +7,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_where { @@ -28,10 +29,7 @@ TEST(mysql, test_where) { Person{ .id = 4, .first_name = "Hugo", .last_name = "Simpson", .age = 10}}); - const auto credentials = sqlgen::mysql::Credentials{.host = "localhost", - .user = "sqlgen", - .password = "password", - .dbname = "mysql"}; + const auto credentials = sqlgen::mysql::test::make_credentials(); using namespace sqlgen; using namespace sqlgen::literals; diff --git a/tests/mysql/test_where_with_operations.cpp b/tests/mysql/test_where_with_operations.cpp index cb3d98e1..d1b46fc6 100644 --- a/tests/mysql/test_where_with_operations.cpp +++ b/tests/mysql/test_where_with_operations.cpp @@ -7,6 +7,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_where_with_operations { @@ -28,10 +29,7 @@ TEST(mysql, test_where_with_operations) { Person{ .id = 4, .first_name = "Hugo", .last_name = "Simpson", .age = 10}}); - const auto credentials = sqlgen::mysql::Credentials{.host = "localhost", - .user = "sqlgen", - .password = "password", - .dbname = "mysql"}; + const auto credentials = sqlgen::mysql::test::make_credentials(); using namespace sqlgen; using namespace sqlgen::literals; diff --git a/tests/mysql/test_where_with_timestamps.cpp b/tests/mysql/test_where_with_timestamps.cpp index 2810053a..d66685f4 100644 --- a/tests/mysql/test_where_with_timestamps.cpp +++ b/tests/mysql/test_where_with_timestamps.cpp @@ -8,6 +8,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_where_with_timestamps { @@ -33,10 +34,7 @@ TEST(mysql, test_where_with_timestamps) { .last_name = "Simpson", .birthday = sqlgen::Date("2010-01-01")}}); - const auto credentials = sqlgen::mysql::Credentials{.host = "localhost", - .user = "sqlgen", - .password = "password", - .dbname = "mysql"}; + const auto credentials = sqlgen::mysql::test::make_credentials(); using namespace sqlgen; using namespace sqlgen::literals; diff --git a/tests/mysql/test_write_and_read.cpp b/tests/mysql/test_write_and_read.cpp index 30c79942..bc40a51e 100644 --- a/tests/mysql/test_write_and_read.cpp +++ b/tests/mysql/test_write_and_read.cpp @@ -7,6 +7,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_write_and_read { @@ -28,10 +29,7 @@ TEST(mysql, test_write_and_read) { using namespace sqlgen; - const auto credentials = mysql::Credentials{.host = "localhost", - .user = "sqlgen", - .password = "password", - .dbname = "mysql"}; + const auto credentials = sqlgen::mysql::test::make_credentials(); const auto conn = mysql::connect(credentials).and_then(drop | if_exists); diff --git a/tests/mysql/test_write_and_read_curried.cpp b/tests/mysql/test_write_and_read_curried.cpp index 5c3f3adb..53d93e5f 100644 --- a/tests/mysql/test_write_and_read_curried.cpp +++ b/tests/mysql/test_write_and_read_curried.cpp @@ -7,6 +7,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_write_and_read_curried { @@ -26,10 +27,7 @@ TEST(mysql, test_write_and_read_curried) { Person{ .id = 3, .first_name = "Maggie", .last_name = "Simpson", .age = 0}}); - const auto credentials = sqlgen::mysql::Credentials{.host = "localhost", - .user = "sqlgen", - .password = "password", - .dbname = "mysql"}; + const auto credentials = sqlgen::mysql::test::make_credentials(); using namespace sqlgen; using namespace sqlgen::literals; diff --git a/tests/mysql/test_write_and_read_pool.cpp b/tests/mysql/test_write_and_read_pool.cpp index dd2bcfec..0e49a904 100644 --- a/tests/mysql/test_write_and_read_pool.cpp +++ b/tests/mysql/test_write_and_read_pool.cpp @@ -7,6 +7,7 @@ #include #include #include +#include "test_helpers.hpp" namespace test_write_and_read_pool { @@ -28,10 +29,7 @@ TEST(mysql, test_write_and_read_pool) { const auto pool_config = sqlgen::ConnectionPoolConfig{.size = 2}; - const auto credentials = sqlgen::mysql::Credentials{.host = "localhost", - .user = "sqlgen", - .password = "password", - .dbname = "mysql"}; + const auto credentials = sqlgen::mysql::test::make_credentials(); const auto pool = sqlgen::make_connection_pool( pool_config, credentials); From 5aa5d34bd252bc38fd65b6b3edaac6842f62a375 Mon Sep 17 00:00:00 2001 From: Marco Craveiro Date: Thu, 5 Feb 2026 10:21:47 +0000 Subject: [PATCH 3/3] Document SQLGEN_TEST_PASSWORD in test helpers Add doc comments explaining that SQLGEN_TEST_PASSWORD environment variable can be set to override the default password for tests. Co-Authored-By: Claude Opus 4.5 --- tests/mysql/test_helpers.hpp | 4 ++++ tests/postgres/test_helpers.hpp | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/tests/mysql/test_helpers.hpp b/tests/mysql/test_helpers.hpp index 0b9bc763..8d5627be 100644 --- a/tests/mysql/test_helpers.hpp +++ b/tests/mysql/test_helpers.hpp @@ -6,6 +6,10 @@ namespace sqlgen::mysql::test { +/// Creates test credentials for MySQL. +/// Set SQLGEN_TEST_PASSWORD environment variable to override the default +/// password ("password"). This allows running tests against an existing +/// database without modifying source code. inline Credentials make_credentials() { const char* env_password = std::getenv("SQLGEN_TEST_PASSWORD"); return Credentials{.host = "localhost", diff --git a/tests/postgres/test_helpers.hpp b/tests/postgres/test_helpers.hpp index 95541760..3f46ba9b 100644 --- a/tests/postgres/test_helpers.hpp +++ b/tests/postgres/test_helpers.hpp @@ -6,8 +6,12 @@ namespace sqlgen::postgres::test { +/// Creates test credentials for PostgreSQL. +/// Set SQLGEN_TEST_PASSWORD environment variable to override the default +/// password ("password"). This allows running tests against an existing +/// database without modifying source code. inline Credentials make_credentials() { - const char* env_password = std::getenv("PGPASSWORD"); + const char* env_password = std::getenv("SQLGEN_TEST_PASSWORD"); return Credentials{.user = "postgres", .password = env_password ? env_password : "password", .host = "localhost",