Skip to content

Commit

Permalink
Add testcase for compiler failure scenario
Browse files Browse the repository at this point in the history
  • Loading branch information
niveathika committed Dec 11, 2023
1 parent 4eb9a56 commit 9dbc7f6
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,19 @@ private Package loadPackage(String path) {
return project.currentPackage();
}

@Test
public void testCompilerErrors() {
Package currentPackage = loadPackage("sample3");
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, 1);
}

@Test(enabled = false)
public void testInvalidConnectionParamConfig() {
Package currentPackage = loadPackage("sample1");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[package]
org = "sql_test"
name = "sample1"
version = "0.1.0"
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// 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 ballerina/sql;

type ConnectionPool record {
int connection?;
}

int|sql:ConnectionPool pool2 = {
maxOpenConnections: 10,
maxConnectionLifeTime: 10,
minIdleConnections: 2
};

public function main() {

}

0 comments on commit 9dbc7f6

Please sign in to comment.