// Copyright 2021 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#include "helper.hpp"

#include <ipmid/api-types.hpp>
#include <optional>
#include <span>
#include <utility>

namespace google
{
namespace ipmi
{

std::pair<std::uint8_t, std::vector<std::uint8_t>>
    ValidateReply(::ipmi::RspType<std::uint8_t, std::vector<uint8_t>> reply,
                  bool hasData)
{
    // Reply is in the form of
    // std::tuple<ipmi::Cc, std::optional<std::tuple<RetTypes...>>>
    EXPECT_EQ(::ipmi::ccSuccess, std::get<0>(reply));

    auto actualReply = std::get<1>(reply);
    EXPECT_TRUE(actualReply.has_value());

    auto subcommand = std::get<0>(*actualReply);
    auto data = std::get<1>(*actualReply);
    EXPECT_EQ(hasData, !data.empty());

    return std::make_pair(subcommand, hasData ? data : std::vector<uint8_t>{});
}

} // namespace ipmi
} // namespace google
