#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));
}
