[ntcore] Pass pub/sub options as a unified PubSubOptions struct (#4794)

In Java, PubSubOption is still used for passing options, but this
simplifies C++ use substantially, as it allows aggregate construction.
This commit is contained in:
Peter Johnson
2022-12-12 19:28:15 -08:00
committed by GitHub
parent f66a667321
commit a865f48e96
53 changed files with 695 additions and 623 deletions

View File

@@ -25,14 +25,19 @@ using ::testing::Return;
namespace nt {
::testing::Matcher<const PubSubOptions&> IsPubSubOptions(
const PubSubOptions& good) {
return AllOf(Field("periodic", &PubSubOptions::periodicMs, good.periodicMs),
Field("pollStorageSize", &PubSubOptions::pollStorageSize,
good.pollStorageSize),
Field("logging", &PubSubOptions::sendAll, good.sendAll),
Field("keepDuplicates", &PubSubOptions::keepDuplicates,
good.keepDuplicates));
::testing::Matcher<const PubSubOptionsImpl&> IsPubSubOptions(
const PubSubOptionsImpl& good) {
return AllOf(
Field("periodic", &PubSubOptionsImpl::periodicMs, good.periodicMs),
Field("pollStorage", &PubSubOptionsImpl::pollStorage, good.pollStorage),
Field("sendAll", &PubSubOptionsImpl::sendAll, good.sendAll),
Field("keepDuplicates", &PubSubOptionsImpl::keepDuplicates,
good.keepDuplicates));
}
::testing::Matcher<const PubSubOptionsImpl&> IsDefaultPubSubOptions() {
static constexpr PubSubOptionsImpl kDefaultPubSubOptionsImpl;
return IsPubSubOptions(kDefaultPubSubOptionsImpl);
}
class LocalStorageTest : public ::testing::Test {
@@ -72,7 +77,7 @@ TEST_F(LocalStorageTest, GetEntryEmptyName) {
TEST_F(LocalStorageTest, GetEntryCached) {
EXPECT_CALL(network, Subscribe(_, wpi::SpanEq({std::string{"tocache"}}),
IsPubSubOptions({})));
IsDefaultPubSubOptions()));
auto entry1 = storage.GetEntry("tocache");
EXPECT_EQ(entry1, storage.GetEntry("tocache"));
@@ -99,7 +104,7 @@ TEST_F(LocalStorageTest, GetTopicInfoUnpublished) {
TEST_F(LocalStorageTest, PublishNewNoProps) {
EXPECT_CALL(network, Publish(_, fooTopic, std::string_view{"foo"},
std::string_view{"boolean"}, wpi::json::object(),
IsPubSubOptions({})));
IsDefaultPubSubOptions()));
storage.Publish(fooTopic, NT_BOOLEAN, "boolean", wpi::json::object(), {});
auto info = storage.GetTopicInfo(fooTopic);
@@ -109,7 +114,7 @@ TEST_F(LocalStorageTest, PublishNewNoProps) {
TEST_F(LocalStorageTest, PublishNewNoPropsNull) {
EXPECT_CALL(network, Publish(_, fooTopic, std::string_view{"foo"},
std::string_view{"boolean"}, wpi::json::object(),
IsPubSubOptions({})));
IsDefaultPubSubOptions()));
storage.Publish(fooTopic, NT_BOOLEAN, "boolean", {}, {});
auto info = storage.GetTopicInfo(fooTopic);
@@ -120,7 +125,7 @@ TEST_F(LocalStorageTest, PublishNew) {
wpi::json properties = {{"persistent", true}};
EXPECT_CALL(network, Publish(_, fooTopic, std::string_view{"foo"},
std::string_view{"boolean"}, properties,
IsPubSubOptions({})));
IsDefaultPubSubOptions()));
storage.Publish(fooTopic, NT_BOOLEAN, "boolean", {{"persistent", true}}, {});
auto info = storage.GetTopicInfo(fooTopic);
@@ -137,12 +142,12 @@ TEST_F(LocalStorageTest, PublishNew) {
TEST_F(LocalStorageTest, SubscribeNoTypeLocalPubPost) {
EXPECT_CALL(network, Subscribe(_, wpi::SpanEq({std::string{"foo"}}),
IsPubSubOptions({})));
IsDefaultPubSubOptions()));
auto sub = storage.Subscribe(fooTopic, NT_UNASSIGNED, "", {});
EXPECT_CALL(network, Publish(_, fooTopic, std::string_view{"foo"},
std::string_view{"boolean"}, wpi::json::object(),
IsPubSubOptions({})));
IsDefaultPubSubOptions()));
auto pub = storage.Publish(fooTopic, NT_BOOLEAN, "boolean", {}, {});
auto val = Value::MakeBoolean(true, 5);
@@ -174,7 +179,7 @@ TEST_F(LocalStorageTest, SubscribeNoTypeLocalPubPost) {
TEST_F(LocalStorageTest, SubscribeNoTypeLocalPubPre) {
EXPECT_CALL(network, Publish(_, fooTopic, std::string_view{"foo"},
std::string_view{"boolean"}, wpi::json::object(),
IsPubSubOptions({})));
IsDefaultPubSubOptions()));
auto pub = storage.Publish(fooTopic, NT_BOOLEAN, "boolean", {}, {});
auto val = Value::MakeBoolean(true, 5);
@@ -182,7 +187,7 @@ TEST_F(LocalStorageTest, SubscribeNoTypeLocalPubPre) {
storage.SetEntryValue(pub, val);
EXPECT_CALL(network, Subscribe(_, wpi::SpanEq({std::string{"foo"}}),
IsPubSubOptions({})));
IsDefaultPubSubOptions()));
auto sub = storage.Subscribe(fooTopic, NT_UNASSIGNED, "", {});
EXPECT_EQ(storage.GetTopicType(fooTopic), NT_BOOLEAN);
@@ -200,14 +205,14 @@ TEST_F(LocalStorageTest, SubscribeNoTypeLocalPubPre) {
TEST_F(LocalStorageTest, EntryNoTypeLocalSet) {
EXPECT_CALL(network, Subscribe(_, wpi::SpanEq({std::string{"foo"}}),
IsPubSubOptions({})));
IsDefaultPubSubOptions()));
auto entry = storage.GetEntry(fooTopic, NT_UNASSIGNED, "", {});
// results in a publish and value set
auto val = Value::MakeBoolean(true, 5);
EXPECT_CALL(network, Publish(_, fooTopic, std::string_view{"foo"},
std::string_view{"boolean"}, wpi::json::object(),
IsPubSubOptions({})));
IsDefaultPubSubOptions()));
EXPECT_CALL(network, SetValue(_, val));
EXPECT_TRUE(storage.SetEntryValue(entry, val));
@@ -246,12 +251,12 @@ TEST_F(LocalStorageTest, EntryNoTypeLocalSet) {
TEST_F(LocalStorageTest, PubUnpubPub) {
EXPECT_CALL(network, Subscribe(_, wpi::SpanEq({std::string{"foo"}}),
IsPubSubOptions({})));
IsDefaultPubSubOptions()));
auto sub = storage.Subscribe(fooTopic, NT_INTEGER, "int", {});
EXPECT_CALL(network, Publish(_, fooTopic, std::string_view{"foo"},
std::string_view{"boolean"}, wpi::json::object(),
IsPubSubOptions({})));
IsDefaultPubSubOptions()));
EXPECT_CALL(logger, Call(NT_LOG_INFO, _, _,
"local subscribe to 'foo' disabled due to type "
"mismatch (wanted 'int', published as 'boolean')"));
@@ -276,7 +281,7 @@ TEST_F(LocalStorageTest, PubUnpubPub) {
EXPECT_CALL(network, Publish(_, fooTopic, std::string_view{"foo"},
std::string_view{"int"}, wpi::json::object(),
IsPubSubOptions({})));
IsDefaultPubSubOptions()));
pub = storage.Publish(fooTopic, NT_INTEGER, "int", {}, {});
val = Value::MakeInteger(3, 5);
@@ -293,7 +298,7 @@ TEST_F(LocalStorageTest, PubUnpubPub) {
TEST_F(LocalStorageTest, LocalPubConflict) {
EXPECT_CALL(network, Publish(_, fooTopic, std::string_view{"foo"},
std::string_view{"boolean"}, wpi::json::object(),
IsPubSubOptions({})));
IsDefaultPubSubOptions()));
auto pub1 = storage.Publish(fooTopic, NT_BOOLEAN, "boolean", {}, {});
EXPECT_CALL(logger, Call(NT_LOG_INFO, _, _,
@@ -314,7 +319,7 @@ TEST_F(LocalStorageTest, LocalPubConflict) {
EXPECT_CALL(network, Unpublish(pub1, fooTopic));
EXPECT_CALL(network, Publish(_, fooTopic, std::string_view{"foo"},
std::string_view{"int"}, wpi::json::object(),
IsPubSubOptions({})));
IsDefaultPubSubOptions()));
storage.Unpublish(pub1);
EXPECT_EQ(storage.GetTopicType(fooTopic), NT_INTEGER);
@@ -330,11 +335,11 @@ TEST_F(LocalStorageTest, LocalPubConflict) {
TEST_F(LocalStorageTest, LocalSubConflict) {
EXPECT_CALL(network, Publish(_, fooTopic, std::string_view{"foo"},
std::string_view{"boolean"}, wpi::json::object(),
IsPubSubOptions({})));
IsDefaultPubSubOptions()));
storage.Publish(fooTopic, NT_BOOLEAN, "boolean", {}, {});
EXPECT_CALL(network, Subscribe(_, wpi::SpanEq({std::string{"foo"}}),
IsPubSubOptions({})));
IsDefaultPubSubOptions()));
EXPECT_CALL(logger, Call(NT_LOG_INFO, _, _,
"local subscribe to 'foo' disabled due to type "
"mismatch (wanted 'int', published as 'boolean')"));
@@ -344,7 +349,7 @@ TEST_F(LocalStorageTest, LocalSubConflict) {
TEST_F(LocalStorageTest, RemotePubConflict) {
EXPECT_CALL(network, Publish(_, fooTopic, std::string_view{"foo"},
std::string_view{"boolean"}, wpi::json::object(),
IsPubSubOptions({})));
IsDefaultPubSubOptions()));
storage.Publish(fooTopic, NT_BOOLEAN, "boolean", {}, {});
@@ -361,7 +366,7 @@ TEST_F(LocalStorageTest, RemotePubConflict) {
EXPECT_CALL(network, Publish(_, fooTopic, std::string_view{"foo"},
std::string_view{"boolean"}, wpi::json::object(),
IsPubSubOptions({})));
IsDefaultPubSubOptions()));
storage.NetworkUnannounce("foo");
@@ -373,14 +378,14 @@ TEST_F(LocalStorageTest, RemotePubConflict) {
TEST_F(LocalStorageTest, SubNonExist) {
// makes sure no warning is emitted
EXPECT_CALL(network, Subscribe(_, wpi::SpanEq({std::string{"foo"}}),
IsPubSubOptions({})));
IsDefaultPubSubOptions()));
storage.Subscribe(fooTopic, NT_BOOLEAN, "boolean", {});
}
TEST_F(LocalStorageTest, SetDefaultSubscribe) {
// no publish, no value on wire, this is just handled locally
EXPECT_CALL(network, Subscribe(_, wpi::SpanEq({std::string{"foo"}}),
IsPubSubOptions({})));
IsDefaultPubSubOptions()));
auto sub = storage.Subscribe(fooTopic, NT_BOOLEAN, "boolean", {});
EXPECT_TRUE(storage.SetDefaultEntryValue(sub, Value::MakeBoolean(true)));
auto val = storage.GetEntryValue(sub);
@@ -392,7 +397,7 @@ TEST_F(LocalStorageTest, SetDefaultSubscribe) {
TEST_F(LocalStorageTest, SetDefaultPublish) {
EXPECT_CALL(network, Publish(_, fooTopic, std::string_view{"foo"},
std::string_view{"boolean"}, wpi::json::object(),
IsPubSubOptions({})));
IsDefaultPubSubOptions()));
auto pub = storage.Publish(fooTopic, NT_BOOLEAN, "boolean", {}, {});
// expect a value across the wire
@@ -400,7 +405,7 @@ TEST_F(LocalStorageTest, SetDefaultPublish) {
EXPECT_CALL(network, SetValue(pub, expectVal));
EXPECT_TRUE(storage.SetDefaultEntryValue(pub, Value::MakeBoolean(true)));
EXPECT_CALL(network, Subscribe(_, _, IsPubSubOptions({})));
EXPECT_CALL(network, Subscribe(_, _, IsDefaultPubSubOptions()));
auto sub = storage.Subscribe(fooTopic, NT_BOOLEAN, "boolean", {});
auto val = storage.GetEntryValue(sub);
ASSERT_TRUE(val.IsBoolean());
@@ -410,13 +415,13 @@ TEST_F(LocalStorageTest, SetDefaultPublish) {
TEST_F(LocalStorageTest, SetDefaultEntry) {
EXPECT_CALL(network, Subscribe(_, wpi::SpanEq({std::string{"foo"}}),
IsPubSubOptions({})));
IsDefaultPubSubOptions()));
auto entry = storage.GetEntry(fooTopic, NT_BOOLEAN, "boolean", {});
// expect a publish and value
EXPECT_CALL(network, Publish(_, fooTopic, std::string_view{"foo"},
std::string_view{"boolean"}, wpi::json::object(),
IsPubSubOptions({})));
IsDefaultPubSubOptions()));
auto expectVal = Value::MakeBoolean(true, 0);
EXPECT_CALL(network, SetValue(_, expectVal));
EXPECT_TRUE(storage.SetDefaultEntryValue(entry, Value::MakeBoolean(true)));
@@ -429,13 +434,13 @@ TEST_F(LocalStorageTest, SetDefaultEntry) {
TEST_F(LocalStorageTest, SetDefaultEntryUnassigned) {
EXPECT_CALL(network, Subscribe(_, wpi::SpanEq({std::string{"foo"}}),
IsPubSubOptions({})));
IsDefaultPubSubOptions()));
auto entry = storage.GetEntry(fooTopic, NT_UNASSIGNED, "", {});
// expect a publish and value
EXPECT_CALL(network, Publish(_, fooTopic, std::string_view{"foo"},
std::string_view{"boolean"}, wpi::json::object(),
IsPubSubOptions({})));
IsDefaultPubSubOptions()));
auto expectVal = Value::MakeBoolean(true, 0);
EXPECT_CALL(network, SetValue(_, expectVal));
EXPECT_TRUE(storage.SetDefaultEntryValue(entry, Value::MakeBoolean(true)));
@@ -450,7 +455,7 @@ TEST_F(LocalStorageTest, SetDefaultEntryUnassigned) {
TEST_F(LocalStorageTest, SetDefaultEntryDiffType) {
EXPECT_CALL(network, Publish(_, fooTopic, std::string_view{"foo"},
std::string_view{"string"}, wpi::json::object(),
IsPubSubOptions({})));
IsDefaultPubSubOptions()));
auto pub = storage.Publish(fooTopic, NT_STRING, "string", {}, {});
EXPECT_FALSE(storage.SetDefaultEntryValue(pub, Value::MakeBoolean(true)));
@@ -460,7 +465,7 @@ TEST_F(LocalStorageTest, SetDefaultEntryDiffType) {
TEST_F(LocalStorageTest, SetValueEmptyValue) {
EXPECT_CALL(network, Publish(_, fooTopic, std::string_view{"foo"},
std::string_view{"string"}, wpi::json::object(),
IsPubSubOptions({})));
IsDefaultPubSubOptions()));
auto pub = storage.Publish(fooTopic, NT_STRING, "string", {}, {});
EXPECT_FALSE(storage.SetEntryValue(pub, {}));
@@ -468,7 +473,7 @@ TEST_F(LocalStorageTest, SetValueEmptyValue) {
TEST_F(LocalStorageTest, SetValueEmptyUntypedEntry) {
EXPECT_CALL(network, Subscribe(_, wpi::SpanEq({std::string{"foo"}}),
IsPubSubOptions({})));
IsDefaultPubSubOptions()));
auto entry = storage.GetEntry(fooTopic, NT_UNASSIGNED, "", {});
EXPECT_FALSE(storage.SetEntryValue(entry, {}));
}
@@ -500,22 +505,21 @@ class LocalStorageDuplicatesTest : public LocalStorageTest {
};
void LocalStorageDuplicatesTest::SetupPubSub(bool keepPub, bool keepSub) {
PubSubOptions pubOptions;
PubSubOptionsImpl pubOptions;
pubOptions.keepDuplicates = keepPub;
EXPECT_CALL(network, Publish(_, fooTopic, std::string_view{"foo"},
std::string_view{"double"}, wpi::json::object(),
IsPubSubOptions(pubOptions)));
pub = storage.Publish(fooTopic, NT_DOUBLE, "double", {},
{{PubSubOption::KeepDuplicates(keepPub)}});
{.keepDuplicates = keepPub});
PubSubOptions subOptions;
subOptions.pollStorageSize = 10;
PubSubOptionsImpl subOptions;
subOptions.pollStorage = 10;
subOptions.keepDuplicates = keepSub;
EXPECT_CALL(network, Subscribe(_, wpi::SpanEq({std::string{"foo"}}),
IsPubSubOptions(subOptions)));
sub = storage.Subscribe(
fooTopic, NT_DOUBLE, "double",
{{PubSubOption::KeepDuplicates(keepSub), PubSubOption::PollStorage(10)}});
sub = storage.Subscribe(fooTopic, NT_DOUBLE, "double",
{.pollStorage = 10, .keepDuplicates = keepSub});
}
void LocalStorageDuplicatesTest::SetValues() {
@@ -839,12 +843,12 @@ TEST_F(LocalStorageTest, ReadQueueLocalRemote) {
EXPECT_CALL(network, Subscribe(_, _, _)).Times(3);
EXPECT_CALL(network, Publish(_, _, _, _, _, _)).Times(1);
auto subBoth = storage.Subscribe(fooTopic, NT_DOUBLE, "double",
{{PubSubOption::AllUpdates()}});
auto subLocal = storage.Subscribe(fooTopic, NT_DOUBLE, "double",
{{PubSubOption::LocalOnly()}});
auto subRemote = storage.Subscribe(fooTopic, NT_DOUBLE, "double",
{{PubSubOption::RemoteOnly()}});
auto subBoth =
storage.Subscribe(fooTopic, NT_DOUBLE, "double", kDefaultPubSubOptions);
auto subLocal =
storage.Subscribe(fooTopic, NT_DOUBLE, "double", {.disableRemote = true});
auto subRemote =
storage.Subscribe(fooTopic, NT_DOUBLE, "double", {.disableLocal = true});
auto pub = storage.Publish(fooTopic, NT_DOUBLE, "double", {}, {});
auto remoteTopic =
storage.NetworkAnnounce("foo", "double", wpi::json::object(), 0);
@@ -874,7 +878,7 @@ TEST_F(LocalStorageTest, SubExcludePub) {
auto pub = storage.Publish(fooTopic, NT_DOUBLE, "double", {}, {});
auto subActive = storage.Subscribe(fooTopic, NT_DOUBLE, "double", {});
auto subExclude = storage.Subscribe(fooTopic, NT_DOUBLE, "double",
{{PubSubOption::ExcludePublisher(pub)}});
{.excludePublisher = pub});
auto remoteTopic =
storage.NetworkAnnounce("foo", "double", wpi::json::object(), 0);
@@ -896,8 +900,8 @@ TEST_F(LocalStorageTest, SubExcludePub) {
TEST_F(LocalStorageTest, EntryExcludeSelf) {
EXPECT_CALL(network, Subscribe(_, _, _));
auto entry = storage.GetEntry(fooTopic, NT_DOUBLE, "double",
{{PubSubOption::ExcludeSelf(true)}});
auto entry =
storage.GetEntry(fooTopic, NT_DOUBLE, "double", {.excludeSelf = true});
auto remoteTopic =
storage.NetworkAnnounce("foo", "double", wpi::json::object(), 0);

View File

@@ -9,18 +9,19 @@
namespace nt {
bool PubSubOptionsMatcher::MatchAndExplain(
const PubSubOptions& val, ::testing::MatchResultListener* listener) const {
const PubSubOptionsImpl& val,
::testing::MatchResultListener* listener) const {
bool match = true;
if (val.periodicMs != good.periodicMs) {
*listener << "periodic mismatch ";
match = false;
}
if (val.pollStorageSize != good.pollStorageSize) {
*listener << "pollStorageSize mismatch ";
if (val.pollStorage != good.pollStorage) {
*listener << "pollStorage mismatch ";
match = false;
}
if (val.sendAll != good.sendAll) {
*listener << "logging mismatch ";
*listener << "sendAll mismatch ";
match = false;
}
if (val.keepDuplicates != good.keepDuplicates) {

View File

@@ -13,21 +13,22 @@
namespace nt {
class PubSubOptionsMatcher
: public ::testing::MatcherInterface<const PubSubOptions&> {
: public ::testing::MatcherInterface<const PubSubOptionsImpl&> {
public:
explicit PubSubOptionsMatcher(PubSubOptions good) : good{std::move(good)} {}
explicit PubSubOptionsMatcher(PubSubOptionsImpl good)
: good{std::move(good)} {}
bool MatchAndExplain(const PubSubOptions& val,
bool MatchAndExplain(const PubSubOptionsImpl& val,
::testing::MatchResultListener* listener) const override;
void DescribeTo(::std::ostream* os) const override;
void DescribeNegationTo(::std::ostream* os) const override;
private:
PubSubOptions good;
PubSubOptionsImpl good;
};
inline ::testing::Matcher<const PubSubOptions&> PubSubOptionsEq(
PubSubOptions good) {
inline ::testing::Matcher<const PubSubOptionsImpl&> PubSubOptionsEq(
PubSubOptionsImpl good) {
return ::testing::MakeMatcher(new PubSubOptionsMatcher(std::move(good)));
}

View File

@@ -160,10 +160,10 @@ void PrintTo(const Value& value, std::ostream* os) {
*os << '}';
}
void PrintTo(const PubSubOptions& options, std::ostream* os) {
void PrintTo(const PubSubOptionsImpl& options, std::ostream* os) {
*os << "PubSubOptions{periodicMs=" << options.periodicMs
<< ", pollStorageSize=" << options.pollStorageSize
<< ", logging=" << options.sendAll
<< ", pollStorage=" << options.pollStorage
<< ", sendAll=" << options.sendAll
<< ", keepDuplicates=" << options.keepDuplicates << '}';
}

View File

@@ -51,7 +51,7 @@ struct ServerMessage;
class Event;
class Handle;
class PubSubOptions;
class PubSubOptionsImpl;
class Value;
void PrintTo(const Event& event, std::ostream* os);
@@ -60,6 +60,6 @@ void PrintTo(const net3::Message3& msg, std::ostream* os);
void PrintTo(const net::ClientMessage& msg, std::ostream* os);
void PrintTo(const net::ServerMessage& msg, std::ostream* os);
void PrintTo(const Value& value, std::ostream* os);
void PrintTo(const PubSubOptions& options, std::ostream* os);
void PrintTo(const PubSubOptionsImpl& options, std::ostream* os);
} // namespace nt

View File

@@ -33,11 +33,11 @@ class MockNetworkStartupInterface : public NetworkStartupInterface {
MOCK_METHOD(void, Publish,
(NT_Publisher pubHandle, NT_Topic topicHandle,
std::string_view name, std::string_view typeStr,
const wpi::json& properties, const PubSubOptions& options),
const wpi::json& properties, const PubSubOptionsImpl& options),
(override));
MOCK_METHOD(void, Subscribe,
(NT_Subscriber subHandle, std::span<const std::string> prefixes,
const PubSubOptions& options),
const PubSubOptionsImpl& options),
(override));
MOCK_METHOD(void, SetValue, (NT_Publisher pubHandle, const Value& value),
(override));
@@ -48,7 +48,7 @@ class MockNetworkInterface : public NetworkInterface {
MOCK_METHOD(void, Publish,
(NT_Publisher pubHandle, NT_Topic topicHandle,
std::string_view name, std::string_view typeStr,
const wpi::json& properties, const PubSubOptions& options),
const wpi::json& properties, const PubSubOptionsImpl& options),
(override));
MOCK_METHOD(void, Unpublish, (NT_Publisher pubHandle, NT_Topic topicHandle),
(override));
@@ -58,7 +58,7 @@ class MockNetworkInterface : public NetworkInterface {
(override));
MOCK_METHOD(void, Subscribe,
(NT_Subscriber subHandle, std::span<const std::string> prefixes,
const PubSubOptions& options),
const PubSubOptionsImpl& options),
(override));
MOCK_METHOD(void, Unsubscribe, (NT_Subscriber subHandle), (override));
MOCK_METHOD(void, SetValue, (NT_Publisher pubHandle, const Value& value),

View File

@@ -31,7 +31,7 @@ class MockClientMessageHandler : public net::ClientMessageHandler {
void(std::string_view name, const wpi::json& update));
MOCK_METHOD3(ClientSubscribe,
void(int64_t subuid, std::span<const std::string> prefixes,
const PubSubOptions& options));
const PubSubOptionsImpl& options));
MOCK_METHOD1(ClientUnsubscribe, void(int64_t subuid));
};

View File

@@ -74,7 +74,7 @@ TEST_F(WireEncoderTextTest, Subscribe) {
}
TEST_F(WireEncoderTextTest, SubscribeSendAll) {
PubSubOptions options;
PubSubOptionsImpl options;
options.sendAll = true;
net::WireEncodeSubscribe(os, 5, std::span<const std::string_view>{{"a", "b"}},
options);
@@ -85,7 +85,7 @@ TEST_F(WireEncoderTextTest, SubscribeSendAll) {
}
TEST_F(WireEncoderTextTest, SubscribePeriodic) {
PubSubOptions options;
PubSubOptionsImpl options;
options.periodicMs = 500u;
net::WireEncodeSubscribe(os, 5, std::span<const std::string_view>{{"a", "b"}},
options);
@@ -96,7 +96,7 @@ TEST_F(WireEncoderTextTest, SubscribePeriodic) {
}
TEST_F(WireEncoderTextTest, SubscribeAllOptions) {
PubSubOptions options;
PubSubOptionsImpl options;
options.sendAll = true;
options.periodicMs = 500u;
net::WireEncodeSubscribe(os, 5, std::span<const std::string_view>{{"a", "b"}},