Basic support for passing postgresql uri on the commandline

This commit is contained in:
eelke 2025-02-17 18:09:19 +01:00
parent 4b4c95e57e
commit 4caccf1000
11 changed files with 453 additions and 192 deletions

View file

@ -19,6 +19,7 @@ SOURCES += main.cpp \
tst_ConvertToMultiLineCString.cpp \
tst_ExplainJsonParser.cpp \
tst_HumanReadableBytes.cpp \
tst_TryParsePostgresqlUrl.cpp \
tst_escapeConnectionStringValue.cpp \
tst_expected.cpp \
tst_SqlLexer.cpp \

View file

@ -0,0 +1,20 @@
#include <gtest/gtest.h>
#include <gmock/gmock-matchers.h>
#include <ConnectionConfig.h>
#include "utils/PostgresqlUrlParser.h"
#include "PrintTo_Qt.h"
using namespace testing;
TEST(TryParsePostgresqlUrl, emptyInput)
{
QString urlString = "postgresql://user:secret@localhost:5433/otherdb?connect_timeout=10&application_name=myapp";
ConnectionConfig config;
bool result = TryParsePostgresqlUrl(urlString, config);
ASSERT_TRUE(result);
ASSERT_THAT(config.user(), Eq("user"));
ASSERT_THAT(config.password(), Eq("secret"));
ASSERT_THAT(config.host(), Eq("localhost"));
ASSERT_THAT(config.dbname(), Eq("otherdb"));
ASSERT_THAT(config.port(), Eq(5433));
}