test/common/config/grpc_mux_impl_test.cc
// Validate behavior when watches has an unknown resource name.
Validate behavior when watches has an unknown resource name.
Validate behavior when watches has an unknown resource name .
TEST_F(GrpcMuxImplTest, WildcardWatch) {
  setup();
  InSequence s;
  const std::string& type_url = Config::TypeUrl::get().ClusterLoadAssignment;
  auto foo_sub = grpc_mux_->subscribe(type_url, {}, callbacks_);
  EXPECT_CALL(*async_client_, start(_, _)).WillOnce(Return(&async_stream_));
  expectSendMessage(type_url, {}, "");
  grpc_mux_->start();
  {
    std::unique_ptr<envoy::api::v2::DiscoveryResponse> response(
        new envoy::api::v2::DiscoveryResponse());
    response->set_type_url(type_url);
    response->set_version_info("1");
    envoy::api::v2::ClusterLoadAssignment load_assignment;
    load_assignment.set_cluster_name("x");
    response->add_resources()->PackFrom(load_assignment);
    EXPECT_CALL(callbacks_, onConfigUpdate(_, "1"))
        .WillOnce(
            Invoke([&load_assignment](const Protobuf::RepeatedPtrField<ProtobufWkt::Any>& resources,
                                      const std::string&) {
              EXPECT_EQ(1, resources.size());
              envoy::api::v2::ClusterLoadAssignment expected_assignment;
              resources[0].UnpackTo(&expected_assignment);
              EXPECT_TRUE(TestUtility::protoEqual(expected_assignment, load_assignment));
            }));
    expectSendMessage(type_url, {}, "1");
    grpc_mux_->onReceiveMessage(std::move(response));
  }
}
TEST_F ( GrpcMuxImplTest , WildcardWatch ) { setup ( ) ; InSequence s ; const std :: string & type_url = Config :: TypeUrl :: get ( ) . ClusterLoadAssignment ; auto foo_sub = grpc_mux_ -> subscribe ( type_url , { } , callbacks_ ) ; EXPECT_CALL ( * async_client_ , start ( _ , _ ) ) . WillOnce ( Return ( & async_stream_ ) ) ; expectSendMessage ( type_url , { } , " " ) ; grpc_mux_ -> start ( ) ; { std :: unique_ptr < envoy :: api :: v2 :: DiscoveryResponse > response ( new envoy :: api :: v2 :: DiscoveryResponse ( ) ) ; response -> set_type_url ( type_url ) ; response -> set_version_info ( " " ) ; envoy :: api :: v2 :: ClusterLoadAssignment load_assignment ; load_assignment . set_cluster_name ( " " ) ; response -> add_resources ( ) -> PackFrom ( load_assignment ) ; EXPECT_CALL ( callbacks_ , onConfigUpdate ( _ , " " ) ) . WillOnce ( Invoke ( [ & load_assignment ] ( const Protobuf :: RepeatedPtrField < ProtobufWkt :: Any > & resources , const std :: string & ) { EXPECT_EQ ( 1 , resources . size ( ) ) ; envoy :: api :: v2 :: ClusterLoadAssignment expected_assignment ; resources [ 0 ] . UnpackTo ( & expected_assignment ) ; EXPECT_TRUE ( TestUtility :: protoEqual ( expected_assignment , load_assignment ) ) ; } ) ) ; expectSendMessage ( type_url , { } , " " ) ; grpc_mux_ -> onReceiveMessage ( std :: move ( response ) ) ; } }
Validate behavior when watches has an unknown resource name.
Validate behavior when watches has an unknown resource name .