Skip to content

Commit

Permalink
Update patch version handling
Browse files Browse the repository at this point in the history
  • Loading branch information
uweseimet committed Dec 7, 2023
1 parent 2786ee1 commit 84e7930
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
3 changes: 3 additions & 0 deletions cpp/s2pctl/s2pctl_display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ string S2pCtlDisplay::DisplayVersionInfo(const PbVersionInfo& version_info) cons
}
else {
version += fmt::format(" {0}.{1}", version_info.major_version(), version_info.minor_version());
if (version_info.patch_version() > 0) {
version += fmt::format(".{}", version_info.patch_version());
}
}

version += version_info.suffix() + "\n";
Expand Down
8 changes: 6 additions & 2 deletions cpp/test/s2pctl_display_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,20 @@ TEST(S2pCtlDisplayTest, DisplayVersionInfo)
info.set_major_version(1);
info.set_minor_version(2);
info.set_patch_version(3);
info.set_identifier("identifier");
string s = display.DisplayVersionInfo(info);
EXPECT_FALSE(s.empty());
EXPECT_EQ(string::npos, s.find("development version"));
EXPECT_NE(string::npos, s.find("1.2.3"));

info.set_patch_version(-1);
s = display.DisplayVersionInfo(info);
EXPECT_FALSE(s.empty());
EXPECT_NE(string::npos, s.find("development version"));
EXPECT_NE(string::npos, s.find("1.2"));

info.set_suffix("rc");
s = display.DisplayVersionInfo(info);
EXPECT_FALSE(s.empty());
EXPECT_NE(string::npos, s.find("rc"));
}

TEST(S2pCtlDisplayTest, DisplayLogLevelInfo)
Expand Down

0 comments on commit 84e7930

Please sign in to comment.