Sha256: 9a301b1a2230c3406b29ff561bb0dc9966c32a36f34be90e874edcb56be22cbc
Contents?: true
Size: 1.83 KB
Versions: 16
Compression:
Stored size: 1.83 KB
Contents
module SubscriptionHelpers def self_serve_subscription( schema: NulogyMessageBusProducer::Specs::TestSchema, subscription_id: SecureRandom.uuid, **query_args ) gql = subscription_query(subscription_id: subscription_id, **query_args) expect { gql_response = execute_graphql(gql, schema) expect(gql_response).to eq(data: {}) }.to change(NulogyMessageBusProducer::SelfServeSubscription, :count).by(1) NulogyMessageBusProducer::SelfServeSubscription.find(subscription_id) end def configured_subscription( schema: NulogyMessageBusProducer::Specs::TestSchema, subscription_id: SecureRandom.uuid, subscription_group_id: SecureRandom.uuid, **query_args ) gql = subscription_query( subscription_id: subscription_id, subscription_group_id: subscription_group_id, **query_args ) NulogyMessageBusProducer.config.add_subscription!( schema: schema.name, query: gql ) end def subscription_query( event_type: "testCreated", query: "foo { id }", subscription_id: SecureRandom.uuid, subscription_group_id: SecureRandom.uuid, topic_name: "some_topic" ) <<~GRAPHQL subscription { #{event_type} ( subscriptionId: "#{subscription_id}", subscriptionGroupId: "#{subscription_group_id}", topicName: "#{topic_name}" ) { #{query} } } GRAPHQL end def execute_graphql(query, schema, variables: {}, context: {}) response = schema.execute( query, variables: variables, context: context, operation_name: nil ) response.to_h.deep_symbolize_keys end def trigger_event(event_type, root_object) schema = NulogyMessageBusProducer::Specs::TestSchema NulogyMessageBusProducer.trigger_event(schema, event_type, root_object) end end
Version data entries
16 entries across 16 versions & 1 rubygems