Skip to content

Commit 396a4f2

Browse files
committed
Test unsupported subscription exception
1 parent 75ba71a commit 396a4f2

File tree

3 files changed

+29
-8
lines changed

3 files changed

+29
-8
lines changed

samples/today/TodayMock.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -539,4 +539,9 @@ service::FieldResult<response::IntType> Expensive::getOrder(service::FieldParams
539539
static_cast<response::IntType>(order));
540540
}
541541

542+
EmptyOperations::EmptyOperations()
543+
: service::Request({}, GetSchema())
544+
{
545+
}
546+
542547
} /* namespace graphql::today */

samples/today/TodayMock.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -636,6 +636,13 @@ class Expensive : public object::Expensive
636636
const size_t order;
637637
};
638638

639+
class EmptyOperations : public service::Request
640+
{
641+
public:
642+
explicit EmptyOperations();
643+
};
644+
645+
639646
} /* namespace graphql::today */
640647

641648
#endif // TODAYMOCK_H

test/TodayTests.cpp

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -708,14 +708,6 @@ TEST_F(TodayServiceCase, SubscribeNextAppointmentChangeOverride)
708708
TEST_F(TodayServiceCase, DeliverNextAppointmentChangeNoSubscriptionObject)
709709
{
710710
auto service = std::make_shared<today::Operations>(nullptr, nullptr, nullptr);
711-
auto query = R"(subscription TestSubscription {
712-
nextAppointment: nextAppointmentChange {
713-
nextAppointmentId: id
714-
when
715-
subject
716-
isNow
717-
}
718-
})"_graphql;
719711
bool exception = false;
720712

721713
try
@@ -731,6 +723,23 @@ TEST_F(TodayServiceCase, DeliverNextAppointmentChangeNoSubscriptionObject)
731723
ASSERT_TRUE(exception) << "expected an exception";
732724
}
733725

726+
TEST_F(TodayServiceCase, DeliverNextAppointmentChangeNoSubscriptionSupport)
727+
{
728+
auto service = std::make_shared<today::EmptyOperations>();
729+
bool exception = false;
730+
731+
try
732+
{
733+
service->deliver("nextAppointmentChange", nullptr);
734+
}
735+
catch (std::logic_error& ex)
736+
{
737+
EXPECT_TRUE(ex.what() == "Subscriptions not supported"sv) << "exception should match";
738+
exception = true;
739+
}
740+
741+
ASSERT_TRUE(exception) << "expected an exception";
742+
}
734743
TEST_F(TodayServiceCase, Introspection)
735744
{
736745
auto query = R"({

0 commit comments

Comments
 (0)