Skip to content

Commit

Permalink
Add a test case to see if plugin validates bal file with errors
Browse files Browse the repository at this point in the history
  • Loading branch information
niveathika committed Dec 5, 2023
1 parent 27b3e77 commit 36328f1
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,20 @@ private Package loadPackage(String path) {
return project.currentPackage();
}

@Test
public void testCompilerErrors() {
Package currentPackage = loadPackage("sample1");
PackageCompilation compilation = currentPackage.getCompilation();
DiagnosticResult diagnosticResult = compilation.diagnosticResult();
List<Diagnostic> diagnosticErrorStream = diagnosticResult.diagnostics().stream()
.filter(r -> r.diagnosticInfo().severity().equals(DiagnosticSeverity.ERROR))
.collect(Collectors.toList());
long availableErrors = diagnosticErrorStream.size();

Assert.assertEquals(availableErrors, 4);
}


@Test
public void testSQLConnectionPoolFieldsInNewExpression() {
Package currentPackage = loadPackage("sample2");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[package]
org = "mysql_test"
name = "sample1"
version = "0.1.0"
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Copyright (c) 2021, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
//
// WSO2 Inc. licenses this file to you under the Apache License,
// Version 2.0 (the "License"); you may not use this file except
// in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

import ballerinax/mysql;

mysql:Client dbClient
mysql:Client dbClient = check new mysql:Client("url", (), (), (), 120, { connectTimeout: -1 }, { maxOpenConnections: -1 });

public function main() returns error? {
}

0 comments on commit 36328f1

Please sign in to comment.