Skip to content
Snippets Groups Projects
Commit ff199afd authored by Ivan Medeiros Monteiro's avatar Ivan Medeiros Monteiro
Browse files

Add unit test

parent 0824c756
No related branches found
No related tags found
2 merge requests!148chore: pass fake credentials instead of empty,!146feat: set http headers via SDManager
Pipeline #143363 failed
/*
Copyright 2022 Schlumberger
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 <cstdlib>
#include <map>
#include <gtest/gtest.h>
#include <Utilities/Environment.h>
#include <FileIO/SDFileManager.h>
using namespace segysdk;
using namespace segysdk::fileio;
using namespace segysdk::utilities;
TEST(SegyIOTests, test_http_header_when_no_environment_variables_are_set)
{
auto sdFileManager = SDFileManager(SDCredentials::none(), CacheSizeOption::none());
auto sdManager = sdFileManager.getSDMananger();
auto header = sdManager->copyHttpHeaders();
ASSERT_EQ(header.find("correlation-id"), header.end());
ASSERT_EQ(header.find("data-partition-id"), header.end());
}
TEST(SegyIOTests, test_http_header_when_environment_variables_are_set)
{
auto envPartition = std::string(EnvironmentVariableStringConsts::OSDU_DATAPARTITIONID + "=test-partition-id");
auto envCorrelation = std::string(EnvironmentVariableStringConsts::CORRELATION_ID + "=test-correlation-id");
ASSERT_EQ(putenv(envPartition.c_str()), 0);
ASSERT_EQ(putenv(envCorrelation.c_str()), 0);
auto sdFileManager = SDFileManager(SDCredentials::none(), CacheSizeOption::none());
auto sdManager = sdFileManager.getSDMananger();
auto header = sdManager->copyHttpHeaders();
auto correlationId_it = header.find("correlation-id");
auto dataPartitionId_it = header.find("data-partition-id");
ASSERT_NE(correlationId_it, header.end());
ASSERT_NE(dataPartitionId_it, header.end());
ASSERT_STREQ(correlationId_it->second.c_str(), "test-correlation-id");
ASSERT_STREQ(dataPartitionId_it->second.c_str(), "test-partition-id");
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment