Skip to content

Commit

Permalink
fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jpihl committed Aug 11, 2023
1 parent b86df06 commit 07a67d0
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions test/src/test_tun_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,23 @@

#include <gtest/gtest.h>
#include <tunnel/tun_interface.hpp>
#include <unistd.h>

TEST(test_tun_interface, construct_no_su_fail)
{
tunnel::tun_interface t;
(void)t;
}

TEST(test_tun_interface, create_no_su_fail)
TEST(test_tun_interface, create_su_expect_fail)
{
tunnel::tun_interface t;
EXPECT_THROW(t.create("dummy", false), std::system_error);
EXPECT_THROW(t.create("dummy", true), std::system_error);
EXPECT_THROW(t.create("too_long_name_way_over_20_chars", false),
std::system_error);
// Check if we are root
if (getuid() == 0)
{
tunnel::tun_interface t;
EXPECT_THROW(t.create("dummy", false), std::system_error);
EXPECT_THROW(t.create("dummy", true), std::system_error);
EXPECT_THROW(t.create("too_long_name_way_over_20_chars", false),
std::system_error);
}
}

0 comments on commit 07a67d0

Please sign in to comment.