From b02b9fb14bceb9badd5a00856f30c0f324c3f962 Mon Sep 17 00:00:00 2001 From: Sasindu Alahakoon Date: Tue, 13 Aug 2024 02:11:43 +0530 Subject: [PATCH] Add test for a non-csv scenario --- .../csvdata/compiler/CompilerPluginTest.java | 10 ++++++++++ .../sample_package_11/Ballerina.toml | 8 ++++++++ .../ballerina_sources/sample_package_11/main.bal | 16 ++++++++++++++++ 3 files changed, 34 insertions(+) create mode 100644 compiler-plugin-test/src/test/resources/ballerina_sources/sample_package_11/Ballerina.toml create mode 100644 compiler-plugin-test/src/test/resources/ballerina_sources/sample_package_11/main.bal diff --git a/compiler-plugin-test/src/test/java/io/ballerina/lib/data/csvdata/compiler/CompilerPluginTest.java b/compiler-plugin-test/src/test/java/io/ballerina/lib/data/csvdata/compiler/CompilerPluginTest.java index aa23f67..a61bdde 100644 --- a/compiler-plugin-test/src/test/java/io/ballerina/lib/data/csvdata/compiler/CompilerPluginTest.java +++ b/compiler-plugin-test/src/test/java/io/ballerina/lib/data/csvdata/compiler/CompilerPluginTest.java @@ -256,4 +256,14 @@ public void testIgnoredCustomHeaderOptions() { Assert.assertEquals(errorDiagnosticsList.get(11).diagnosticInfo() .messageFormat(), IGNORE_OUTPUT_HEADERS_FOR_RECORD_ARRAY); } + + @Test + public void testNonCsvFunctionCall() { + DiagnosticResult diagnosticResult = + CompilerPluginTestUtils.loadPackage("sample_package_11").getCompilation().diagnosticResult(); + List errorDiagnosticsList = diagnosticResult.diagnostics().stream() + .filter(r -> r.diagnosticInfo().severity().equals(DiagnosticSeverity.ERROR)) + .collect(Collectors.toList()); + Assert.assertEquals(errorDiagnosticsList.size(), 0); + } } diff --git a/compiler-plugin-test/src/test/resources/ballerina_sources/sample_package_11/Ballerina.toml b/compiler-plugin-test/src/test/resources/ballerina_sources/sample_package_11/Ballerina.toml new file mode 100644 index 0000000..26a2006 --- /dev/null +++ b/compiler-plugin-test/src/test/resources/ballerina_sources/sample_package_11/Ballerina.toml @@ -0,0 +1,8 @@ +[package] +org = "wso2" +name = "sample_package_11" +version = "0.1.0" +distribution = "2201.9.2" + +[build-options] +observabilityIncluded = true diff --git a/compiler-plugin-test/src/test/resources/ballerina_sources/sample_package_11/main.bal b/compiler-plugin-test/src/test/resources/ballerina_sources/sample_package_11/main.bal new file mode 100644 index 0000000..d25595b --- /dev/null +++ b/compiler-plugin-test/src/test/resources/ballerina_sources/sample_package_11/main.bal @@ -0,0 +1,16 @@ +import ballerina/data.csv; + +type A record { + int:Unsigned32 headerRows = 0; + string[] customHeaders = []; + boolean outputWithHeaders = false; +}; + +public function main() returns error? { + record {}[] a = check csv:parseString(string `a,b`, {}); + record {}[] b = test({headerRows: 2, outputWithHeaders: false}); +} + +function test(A a) returns record{}[] { + return [{}]; +}