#include <sdbusplus/bus.hpp>
#include <sdeventplus/event.hpp>
#include <systemd_target_signal.hpp>

#include <iostream>

#include <gtest/gtest.h>

// Enable debug by default for debug when needed
bool gVerbose = true;

TEST(TargetSignalData, BasicPaths)
{
    // Create default data structure for testing
    TargetErrorData targetData = {
        {"multi-user.target",
         {"xyz.openbmc_project.State.BMC.Error.MultiUserTargetFailure",
          {"default"}}},
        {"obmc-chassis-poweron@0.target",
         {"xyz.openbmc_project.State.Chassis.Error.PowerOnTargetFailure",
          {"timeout", "failed"}}}};

    ServiceMonitorData serviceData = {
        "xyz.openbmc_project.biosconfig_manager.service",
        "xyz.openbmc_project.Dump.Manager.service"};

    auto bus = sdbusplus::bus::new_default();
    auto event = sdeventplus::Event::get_default();
    bus.attach_event(event.get(), SD_EVENT_PRIORITY_NORMAL);

    phosphor::state::manager::SystemdTargetLogging targetMon(
        targetData, serviceData, bus);

    std::string invalidUnit = "invalid_unit";
    std::string validError = "timeout";
    std::string errorToLog = targetMon.processError(invalidUnit, validError);
    EXPECT_TRUE(errorToLog.empty());

    std::string validUnit = "obmc-chassis-poweron@0.target";
    std::string invalidError = "invalid_error";
    errorToLog = targetMon.processError(validUnit, invalidError);
    EXPECT_TRUE(errorToLog.empty());

    errorToLog = targetMon.processError(validUnit, validError);
    EXPECT_FALSE(errorToLog.empty());
    EXPECT_EQ(errorToLog,
              "xyz.openbmc_project.State.Chassis.Error.PowerOnTargetFailure");
}
