Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: In rest_server_test Allow "view-localhost" hostname #1282

Merged
merged 1 commit into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions tests/rest_server_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,14 @@ TEST(rest_server_test, basic_test)
ASSERT_EQ(res->status, 200);

// TODO: Clean this up to use proper gtest macros.
// NOTE: res->body is "ip6-localhost" on some architectures.
if (res->body == "ip6-localhost")
if ((res->body.length() >= 9) && // 9 being len of "localhost"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of hardcoding 9, you could write strlen("localhost"). It's self-documenting

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or, even better, you can use EXPECT_THAT(res->body, testing::EndsWith("localhost"))

(0 == res->body.compare(res->body.length() - 9, 9, "localhost")))
{
ASSERT_EQ(res->body, "ip6-localhost"); // count the passing test.
}
else if (res->body == "localhost")
{
ASSERT_EQ(res->body, "localhost");
// NOTE: res->body is "localhost", or "ip6-localhost", or (seen on
// Windows 10) "view-localhost" on some architectures.
// We are checking for res->body ends in "localhost"
ASSERT_TRUE(
0 == res->body.compare(res->body.length() - 9, 9, "localhost"));
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.4.30.20250113
0.4.31.20250114
Loading