Skip to content

Commit

Permalink
Enable subscription tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ThisaruGuruge committed Mar 10, 2025
1 parent b5e55c8 commit 67dd77b
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 99 deletions.
3 changes: 1 addition & 2 deletions ballerina-tests/tests/01_listener_test.bal
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,7 @@ function testAttachServiceWithMutationToHttp1BasedListenerAndClient() returns er
}

@test:Config {
groups: ["listener", "subscriptions"],
enable: false
groups: ["listener", "subscriptions"]
}
function testAttachServiceWithSubscriptionToHttp1BasedListener() returns error? {
string document = string `subscription { messages }`;
Expand Down
18 changes: 6 additions & 12 deletions ballerina-tests/tests/02_request_validation.bal
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,7 @@ isolated function testInvalidRequestBody() returns error? {
}

@test:Config {
groups: ["request_validation", "websocket", "subscriptions"],
enable: false
groups: ["request_validation", "websocket", "subscriptions"]
}
isolated function testInvalidWebSocketRequestWithEmptyQuery() returns error? {
string document = "";
Expand All @@ -162,8 +161,7 @@ isolated function testInvalidWebSocketRequestWithEmptyQuery() returns error? {
}

@test:Config {
groups: ["request_validation", "websocket", "subscriptions"],
enable: false
groups: ["request_validation", "websocket", "subscriptions"]
}
isolated function testInvalidWebSocketRequestWithInvalidQuery() returns error? {
string url = "ws://localhost:9099/subscriptions";
Expand All @@ -178,8 +176,7 @@ isolated function testInvalidWebSocketRequestWithInvalidQuery() returns error? {
}

@test:Config {
groups: ["request_validation", "websocket", "subscriptions"],
enable: false
groups: ["request_validation", "websocket", "subscriptions"]
}
isolated function testInvalidWebSocketRequestWithoutQuery() returns error? {
string url = "ws://localhost:9099/subscriptions";
Expand All @@ -193,8 +190,7 @@ isolated function testInvalidWebSocketRequestWithoutQuery() returns error? {
}

@test:Config {
groups: ["request_validation", "websocket", "subscriptions"],
enable: false
groups: ["request_validation", "websocket", "subscriptions"]
}
isolated function testInvalidVariableInWebSocketPayload() returns error? {
string document = check getGraphqlDocumentFromFile("subscriptions_with_variable_values");
Expand All @@ -210,8 +206,7 @@ isolated function testInvalidVariableInWebSocketPayload() returns error? {
}

@test:Config {
groups: ["request_validation", "websocket", "subscriptions"],
enable: false
groups: ["request_validation", "websocket", "subscriptions"]
}
isolated function testEmptyWebSocketPayload() returns error? {
string url = "ws://localhost:9099/subscriptions";
Expand All @@ -225,8 +220,7 @@ isolated function testEmptyWebSocketPayload() returns error? {
}

@test:Config {
groups: ["request_validation", "websocket", "subscriptions"],
enable: false
groups: ["request_validation", "websocket", "subscriptions"]
}
isolated function testInvalidWebSocketPayload() returns error? {
string url = "ws://localhost:9099/subscriptions";
Expand Down
3 changes: 1 addition & 2 deletions ballerina-tests/tests/27_context.bal
Original file line number Diff line number Diff line change
Expand Up @@ -317,8 +317,7 @@ isolated function testContextWithSubscriptions() returns error? {
}

@test:Config {
groups: ["context", "subscriptions"],
enable: false
groups: ["context", "subscriptions"]
}
isolated function testContextWithInvalidScopeInSubscriptions() returns error? {
string url = "ws://localhost:9092/context";
Expand Down
3 changes: 1 addition & 2 deletions ballerina-tests/tests/34_graphiql_client.bal
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ import ballerina/http;
import ballerina/test;

@test:Config {
groups: ["listener", "graphiql"],
enable: false
groups: ["listener", "graphiql"]
}
function testGraphiqlWithSamePathAsGraphQLService() returns error? {
graphql:Error? result = basicListener.attach(graphiqlConfigService, "ballerina/graphiql");
Expand Down
78 changes: 26 additions & 52 deletions ballerina-tests/tests/36_subscriptions.bal
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ import ballerina/test;
import ballerina/websocket;

@test:Config {
groups: ["subscriptions"],
enable: false
groups: ["subscriptions"]
}
isolated function testSubscription() returns error? {
string document = string `subscription { name }`;
Expand All @@ -36,8 +35,7 @@ isolated function testSubscription() returns error? {
}

@test:Config {
groups: ["subscriptions"],
enable: false
groups: ["subscriptions"]
}
isolated function testSubscriptionWithoutSubProtocol() returns error? {
string url = "ws://localhost:9099/subscriptions";
Expand All @@ -48,8 +46,7 @@ isolated function testSubscriptionWithoutSubProtocol() returns error? {
}

@test:Config {
groups: ["subscriptions"],
enable: false
groups: ["subscriptions"]
}
isolated function testSubscriptionsWithMultipleOperations() returns error? {
string document = check getGraphqlDocumentFromFile("subscriptions_with_multiple_operations");
Expand Down Expand Up @@ -78,8 +75,7 @@ isolated function testSubscriptionsWithMultipleOperations() returns error? {
}

@test:Config {
groups: ["records", "subscriptions"],
enable: false
groups: ["records", "subscriptions"]
}
isolated function testSubscriptionWithRecords() returns error? {
string document = check getGraphqlDocumentFromFile("subscriptions_with_records");
Expand All @@ -96,8 +92,7 @@ isolated function testSubscriptionWithRecords() returns error? {
}

@test:Config {
groups: ["subscriptions"],
enable: false
groups: ["subscriptions"]
}
isolated function testQueryWithSameSubscriptionFieldName() returns error? {
string document = string `query { name }`;
Expand All @@ -108,8 +103,7 @@ isolated function testQueryWithSameSubscriptionFieldName() returns error? {
}

@test:Config {
groups: ["fragments", "subscriptions"],
enable: false
groups: ["fragments", "subscriptions"]
}
isolated function testSubscriptionWithFragments() returns error? {
string document = check getGraphqlDocumentFromFile("subscriptions_with_fragments");
Expand All @@ -126,8 +120,7 @@ isolated function testSubscriptionWithFragments() returns error? {
}

@test:Config {
groups: ["union", "subscriptions"],
enable: false
groups: ["union", "subscriptions"]
}
isolated function testSubscriptionWithUnionType() returns error? {
string document = check getGraphqlDocumentFromFile("subscriptions_with_union_type");
Expand All @@ -144,8 +137,7 @@ isolated function testSubscriptionWithUnionType() returns error? {
}

@test:Config {
groups: ["variables", "subscriptions"],
enable: false
groups: ["variables", "subscriptions"]
}
isolated function testSubscriptionWithVariables() returns error? {
string document = check getGraphqlDocumentFromFile("subscriptions_with_variable_values");
Expand All @@ -163,8 +155,7 @@ isolated function testSubscriptionWithVariables() returns error? {
}

@test:Config {
groups: ["introspection", "typename", "subscriptions"],
enable: false
groups: ["introspection", "typename", "subscriptions"]
}
isolated function testSubscriptionWithIntrospectionInFields() returns error? {
string document = string `subscription { students { __typename } }`;
Expand All @@ -179,8 +170,7 @@ isolated function testSubscriptionWithIntrospectionInFields() returns error? {
}

@test:Config {
groups: ["subscriptions"],
enable: false
groups: ["subscriptions"]
}
isolated function testInvalidSubscription() returns error? {
string document = string `subscription { invalidField }`;
Expand All @@ -195,8 +185,7 @@ isolated function testInvalidSubscription() returns error? {
}

@test:Config {
groups: ["subscriptions"],
enable: false
groups: ["subscriptions"]
}
isolated function testSubscriptionFunctionWithErrors() returns error? {
string document = string `subscription getNames { values }`;
Expand All @@ -217,8 +206,7 @@ isolated function testSubscriptionFunctionWithErrors() returns error? {
}

@test:Config {
groups: ["service", "subscriptions"],
enable: false
groups: ["service", "subscriptions"]
}
isolated function testSubscriptionWithServiceObjects() returns error? {
string document = check getGraphqlDocumentFromFile("subscriptions_with_service_objects");
Expand All @@ -236,8 +224,7 @@ isolated function testSubscriptionWithServiceObjects() returns error? {
}

@test:Config {
groups: ["subscriptions"],
enable: false
groups: ["subscriptions"]
}
isolated function testSubscriptionWithMultipleClients() returns error? {
string document = string `subscription { messages }`;
Expand All @@ -262,8 +249,7 @@ isolated function testSubscriptionWithMultipleClients() returns error? {
}

@test:Config {
groups: ["subscriptions"],
enable: false
groups: ["subscriptions"]
}
isolated function testConnectionInitMessage() returns error? {
string url = "ws://localhost:9099/subscriptions";
Expand All @@ -274,8 +260,7 @@ isolated function testConnectionInitMessage() returns error? {
}

@test:Config {
groups: ["subscriptions"],
enable: false
groups: ["subscriptions"]
}
isolated function testInvalidMultipleConnectionInitMessages() returns error? {
string url = "ws://localhost:9099/subscriptions";
Expand All @@ -289,8 +274,7 @@ isolated function testInvalidMultipleConnectionInitMessages() returns error? {
}

@test:Config {
groups: ["subscriptions"],
enable: false
groups: ["subscriptions"]
}
isolated function testUnauthorizedAccess() returns error? {
string document = check getGraphqlDocumentFromFile("subscriptions_with_service_objects");
Expand All @@ -304,8 +288,7 @@ isolated function testUnauthorizedAccess() returns error? {
}

@test:Config {
groups: ["subscriptions"],
enable: false
groups: ["subscriptions"]
}
function testAlreadyExistingSubscriber() returns error? {
string document = check getGraphqlDocumentFromFile("subscriptions_with_service_objects");
Expand Down Expand Up @@ -337,8 +320,7 @@ function testAlreadyExistingSubscriber() returns error? {
}

@test:Config {
groups: ["subscriptions"],
enable: false
groups: ["subscriptions"]
}
isolated function testOnPing() returns error? {
string url = "ws://localhost:9099/subscriptions";
Expand All @@ -350,8 +332,7 @@ isolated function testOnPing() returns error? {
}

@test:Config {
groups: ["subscriptions"],
enable: false
groups: ["subscriptions"]
}
isolated function testInvalidSubProtocolInSubscriptions() returns error? {
string url = "ws://localhost:9099/subscriptions";
Expand All @@ -365,8 +346,7 @@ isolated function testInvalidSubProtocolInSubscriptions() returns error? {
}

@test:Config {
groups: ["subscriptions", "runtime_errors"],
enable: false
groups: ["subscriptions", "runtime_errors"]
}
isolated function testErrorsInStreams() returns error? {
string document = "subscription { evenNumber }";
Expand All @@ -385,8 +365,7 @@ isolated function testErrorsInStreams() returns error? {
}

@test:Config {
groups: ["subscriptions"],
enable: false
groups: ["subscriptions"]
}
isolated function testMultipleSubscriptionUsingSingleClient() returns error? {
string document = string `subscription { messages }`;
Expand All @@ -411,8 +390,7 @@ isolated function testMultipleSubscriptionUsingSingleClient() returns error? {
}

@test:Config {
groups: ["subscriptions"],
enable: false
groups: ["subscriptions"]
}
isolated function testSubscriptionWithInvalidPayload() returns error? {
string url = "ws://localhost:9099/subscriptions";
Expand All @@ -428,8 +406,7 @@ isolated function testSubscriptionWithInvalidPayload() returns error? {
}

@test:Config {
groups: ["subscriptions", "records", "service"],
enable: false
groups: ["subscriptions", "records", "service"]
}
isolated function testResolverReturingStreamOfRecordsWithServiceObjects() returns error? {
string document = "subscription { live { product { id } score } }";
Expand All @@ -444,8 +421,7 @@ isolated function testResolverReturingStreamOfRecordsWithServiceObjects() return
}

@test:Config {
groups: ["subscriptions", "records", "service", "maps"],
enable: false
groups: ["subscriptions", "records", "service", "maps"]
}
isolated function testResolverReturingStreamOfRecordsWithMapOfServiceObjects() returns error? {
string document = string `subscription { accountUpdates { details(key: "acc1") { name } } }`;
Expand All @@ -462,8 +438,7 @@ isolated function testResolverReturingStreamOfRecordsWithMapOfServiceObjects() r
}

@test:Config {
groups: ["subscriptions", "multiplexing"],
enable: false
groups: ["subscriptions", "multiplexing"]
}
isolated function testSubscriptionMultiplexing() returns error? {
string document = string `subscription { refresh }`;
Expand Down Expand Up @@ -498,8 +473,7 @@ isolated function testSubscriptionMultiplexing() returns error? {
}

@test:Config {
groups: ["subscriptions", "records", "service"],
enable: false
groups: ["subscriptions", "records", "service"]
}
isolated function testConnectionClousureWhenPongNotRecived() returns error? {
string url = "ws://localhost:9090/reviews";
Expand Down
Loading

0 comments on commit 67dd77b

Please sign in to comment.