Skip to content

Commit

Permalink
Merge pull request #3327 from canonical/find-default-no-snapcraft-remote
Browse files Browse the repository at this point in the history
[daemon/find] Filter out snapcraft remote by default
  • Loading branch information
ricab authored Dec 12, 2023
2 parents c4e27da + 85dc6cb commit 0339166
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/daemon/daemon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1649,7 +1649,8 @@ try // clang-format on
std::unordered_set<std::string> images_found;
auto action = [&images_found, &default_remote, request, &response](const std::string& remote,
const mp::VMImageInfo& info) {
if ((info.supported || request->allow_unsupported()) && !info.aliases.empty() &&
if (remote != mp::snapcraft_remote && (info.supported || request->allow_unsupported()) &&
!info.aliases.empty() &&
images_found.find(info.release_title.toStdString()) == images_found.end())
{
add_aliases(response.mutable_images_info(), remote, info, default_remote);
Expand Down
8 changes: 5 additions & 3 deletions tests/test_daemon_find.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,16 @@ TEST_F(DaemonFind, blankQueryReturnsAllData)

EXPECT_THAT(stream.str(), AllOf(HasSubstr(mpt::default_alias), HasSubstr(mpt::default_release_info),
HasSubstr(mpt::another_alias), HasSubstr(mpt::another_release_info),
HasSubstr(fmt::format("{}:{}", mpt::snapcraft_remote, mpt::snapcraft_alias)),
HasSubstr(mpt::snapcraft_release_info),
HasSubstr(fmt::format("{}:{}", mpt::custom_remote, mpt::custom_alias)),
HasSubstr(mpt::custom_release_info), HasSubstr(blueprint1_name),
HasSubstr(blueprint_description_for(blueprint1_name)), HasSubstr(blueprint2_name),
HasSubstr(blueprint_description_for(blueprint2_name))));

EXPECT_EQ(total_lines_of_output(stream), 10);
EXPECT_THAT(stream.str(),
Not(AllOf(HasSubstr(fmt::format("{}:{}", mpt::snapcraft_remote, mpt::snapcraft_alias)),
HasSubstr(mpt::snapcraft_release_info))));

EXPECT_EQ(total_lines_of_output(stream), 9);
}

TEST_F(DaemonFind, queryForDefaultReturnsExpectedData)
Expand Down

0 comments on commit 0339166

Please sign in to comment.