Skip to content
Snippets Groups Projects
Commit e6dbe221 authored by Huste, Tobias's avatar Huste, Tobias
Browse files

Merge branch 'ci-episode-5-exercise-1-remove-redundancies-in-ci-pipeline' into...

Merge branch 'ci-episode-5-exercise-1-remove-redundancies-in-ci-pipeline' into ci-episode-6-exercise-1-optimize-ci-pipeline
parents cde97a1f 66938fa3
No related branches found
No related tags found
No related merge requests found
Pipeline #467665 passed
...@@ -74,9 +74,9 @@ test:gcc: ...@@ -74,9 +74,9 @@ test:gcc:
running: running:
stage: run stage: run
image: gcc:13 image: gcc:14
script: script:
- ./build_gcc_13/bin/helloWorld - ./build_gcc_14/bin/helloWorld
needs: needs:
- job: "build:gcc" - job: "build:gcc"
artifacts: true artifacts: true
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
#include <iostream> #include <iostream>
#include <string>
#include "src/helloworld.h" #include "src/helloworld.h"
......
...@@ -4,41 +4,42 @@ ...@@ -4,41 +4,42 @@
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include <cstdlib> #include <cstdlib>
#include <string>
#include "src/helloworld.h" #include "src/helloworld.h"
namespace { namespace {
TEST(getUserNameViaEnv, HandleEnvUnset) { TEST(getUserNameViaEnv, HandleEnvUnset) {
// Test if function returns World if environment variable unset // Test if function returns World if environment variable unset
// Make sure environment variable is unset // Make sure environment variable is unset
char* envVarNameChar; char* envVarNameChar;
std::string envVarName = std::string{"GITLAB_USER_NAME"}; std::string envVarName = std::string{"GITLAB_USER_NAME"};
envVarNameChar = &envVarName[0]; envVarNameChar = &envVarName[0];
unsetenv(envVarNameChar); unsetenv(envVarNameChar);
// Assert that we get the expected result // Assert that we get the expected result
EXPECT_EQ(std::string{"World"}, getUserNameViaEnv()); EXPECT_EQ(std::string{"World"}, getUserNameViaEnv());
} }
TEST(getUserNameViaEnv, HandleEnvSet) { TEST(getUserNameViaEnv, HandleEnvSet) {
// Test if function returns World if environment variable unset // Test if function returns World if environment variable unset
// Set the environment variable to the desired value // Set the environment variable to the desired value
char* envVarNameChar; char* envVarNameChar;
char* envVarValChar; char* envVarValChar;
std::string envVarName = std::string{"GITLAB_USER_NAME"}; std::string envVarName = std::string{"GITLAB_USER_NAME"};
std::string envVarVal = std::string{"Jane Doe"}; std::string envVarVal = std::string{"Jane Doe"};
envVarNameChar = &envVarName[0]; envVarNameChar = &envVarName[0];
envVarValChar = &envVarVal[0]; envVarValChar = &envVarVal[0];
setenv(envVarNameChar, envVarValChar, true); setenv(envVarNameChar, envVarValChar, true);
// Assert that function output and environment variable are similar // Assert that function output and environment variable are similar
EXPECT_EQ(envVarVal, getUserNameViaEnv()); EXPECT_EQ(envVarVal, getUserNameViaEnv());
// Clean up // Clean up
unsetenv(envVarNameChar); unsetenv(envVarNameChar);
} }
} // namespace } // namespace
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