From c5229905cc9a50a2686955ddf36b57d7eabced16 Mon Sep 17 00:00:00 2001 From: Amith Mihiranga Date: Tue, 2 Jul 2024 10:33:11 +0530 Subject: [PATCH 1/2] Update test code generated for service template Improve test code generated for service template by ballerina-cli --- .../create_cmd_templates/service/tests/service_test.bal | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cli/ballerina-cli/src/main/resources/create_cmd_templates/service/tests/service_test.bal b/cli/ballerina-cli/src/main/resources/create_cmd_templates/service/tests/service_test.bal index 0d85eb25166e..d5a1bc5ffad3 100644 --- a/cli/ballerina-cli/src/main/resources/create_cmd_templates/service/tests/service_test.bal +++ b/cli/ballerina-cli/src/main/resources/create_cmd_templates/service/tests/service_test.bal @@ -15,7 +15,7 @@ function beforeSuiteFunc() { @test:Config {} function testServiceWithProperName() { - string|error response = testClient->get("/greeting/?name=John"); + string|error response = testClient->/greeting(name = "John"); test:assertEquals(response, "Hello, John"); } @@ -23,7 +23,7 @@ function testServiceWithProperName() { @test:Config {} function testServiceWithEmptyName() returns error? { - http:Response response = check testClient->get("/greeting/"); + http:Response response = check testClient->/greeting; test:assertEquals(response.statusCode, 500); json errorPayload = check response.getJsonPayload(); test:assertEquals(errorPayload.message, "name should not be empty!"); From 1a2e42134696d415e787166a6729f910fe5f0f81 Mon Sep 17 00:00:00 2001 From: Amith Mihiranga Date: Tue, 2 Jul 2024 12:33:41 +0530 Subject: [PATCH 2/2] Remove unnecessary whitespaces --- .../create_cmd_templates/service/tests/service_test.bal | 4 ---- 1 file changed, 4 deletions(-) diff --git a/cli/ballerina-cli/src/main/resources/create_cmd_templates/service/tests/service_test.bal b/cli/ballerina-cli/src/main/resources/create_cmd_templates/service/tests/service_test.bal index d5a1bc5ffad3..ba97e3bac6d0 100644 --- a/cli/ballerina-cli/src/main/resources/create_cmd_templates/service/tests/service_test.bal +++ b/cli/ballerina-cli/src/main/resources/create_cmd_templates/service/tests/service_test.bal @@ -5,14 +5,12 @@ import ballerina/test; http:Client testClient = check new ("http://localhost:9090"); // Before Suite Function - @test:BeforeSuite function beforeSuiteFunc() { io:println("I'm the before suite function!"); } // Test function - @test:Config {} function testServiceWithProperName() { string|error response = testClient->/greeting(name = "John"); @@ -20,7 +18,6 @@ function testServiceWithProperName() { } // Negative test function - @test:Config {} function testServiceWithEmptyName() returns error? { http:Response response = check testClient->/greeting; @@ -30,7 +27,6 @@ function testServiceWithEmptyName() returns error? { } // After Suite Function - @test:AfterSuite function afterSuiteFunc() { io:println("I'm the after suite function!");